Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

confusing cookies  RSS feed

Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i hav been using cookies . if cookies r used for session tracking
they ideally r of no use once the session expires (i.e once the user closes his browser window) then what is the point in giving a max age of n number of days to the cookie so that it resides for that number of days on the client side.
as i assume when the user closes his browser andthen again requests for the page a new session will be started for which another cookie will be set .

i hav made a simple cookie example which i create it one servlet ,
give it a max age of 2 days and then add it to httpresponse object and retrieve it on the second servlet. now i open one ie browser window use that servlet and see the cookie value in the second servlet and close the browser. now ideally this cookie must reside in my machine for 2 days. i can see the cookie in the temp internet files
now after that i open another browser window again request for the same servlet now again i retrieve the content of the cookie
but it doesnot create another cookie txt file in theTemp internet files but just replaces the previous cookie.txt file with the new value i giv to the cookie. ideally what should happen in such a scenario.
the getCookies method associated
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!