aspose file tools*
The moose likes Servlets and the fly likes problem in cookie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in cookie" Watch "problem in cookie" New topic
Author

problem in cookie

sevi satalkar
Greenhorn

Joined: Mar 03, 2004
Posts: 7
Hello there ,

i am facing problem with cookies ,i have also made session in the coding-
* it is storing a JSESSIONID & its corresponding value,eventhough i am not setting in it.
* also , plz. tell me the way if we can destroy the cookie that is
already present ,created by another user , before surfing the site .
Thanx !!!
-- sevika satalkar
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
JSESSIONID is the name of the cookie for the session. If you created a session for the client, it's going to have a cookie like this (or a rewritten address, e.g. http://www.microsoft.com/;JSESSIONID=23593 -- something like that anyways).
As for deleting the cookie, you're going about it the wrong way. In fact, you shouldn't be depending on the use of cookies when you utilize sessions in your web application. Remember, the URLs may have to be rewritten instead of using cookies all the time (in case the client has disabled them).
Short answer though: use HttpSession.invalidate(). This will kill the session, and any sort of cookies associated with it. If you're thinking about trying to delete the cookie manually, don't! You'll probably experience a bit of heartache doing it that way. Use the API for these things--that's what it's there for!


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
sevi satalkar
Greenhorn

Joined: Mar 03, 2004
Posts: 7
hi ,
thanks for giving such a quick response .
in servlet api i have read this --

setMaxAge(int ) :-
A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is the maximum age when the cookie will expire, not the cookie's current age.
A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A zero value causes the cookie to be deleted.
when should be it set to zero , just before any one starts surfing the
site , will it do .
 
 
subject: problem in cookie