• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cookies

 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hfsj says that cookies can contain name/value string pairs...example whenever i start my gmail page it already contains my name and password...but what does
But you can tell a cookie to stay alive even after the browser shuts down
mean?

i thought cookie is associated with a session and session ends with the shut down of the browser..can anyone clarify
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cookies and sessions are a different thing. JavaEE uses Cookies to identify clients associated with a particular session (this is just one of the ways to identify a client's session). You can create cookies on the client machine independently of the session. There's no need for a session to be present for sending a cookie with a response...
 
Swagato Bhatta
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Jain Kothari wrote:hfsj says that cookies can contain name/value string pairs...example whenever i start my gmail page it already contains my name and password...but what does
But you can tell a cookie to stay alive even after the browser shuts down
mean?

i thought cookie is associated with a session and session ends with the shut down of the browser..can anyone clarify


Session uses cookies to make stateful conversation. AM I right? ??

Since webcontainers are stateless, cookies are used. Now when browser is shut down or the session ends, the cookie can still sruvive. I think in web.xml you can say for how long you can keep the cookie to stay alive. I am reading right now in the book that it can also be done programetically.. but I have not tried that yet.

Anyhow, yes cookie can stay alive long after your browser is not there. However, a session can be there without cookie. Imagine a situation where the client has deliberately disabled cookie. What happens then? I think you can then use sessionID appened to browser URL ....Am I right? Actually the webconatiner does this for you? However, you have to say it somewhere...umm still studying that....

That is my knowledge so far about this. Hope this helps somehow
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the age of the cookie can be altered programmatically and not in the web.xml file. Only the age of session can be done both ways.
I think in web.xml you can say for how long you can keep the cookie to stay alive.
 
Swagato Bhatta
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Jain Kothari wrote:the age of the cookie can be altered programmatically and not in the web.xml file. Only the age of session can be done both ways.
I think in web.xml you can say for how long you can keep the cookie to stay alive.


oh yes thanks :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic