06-13-2005, 12:37 PM | #1 (permalink) |
Free Mars!
Location: I dunno, there's white people around me saying "eh" all the time
|
[Java] Cookies vs Session
I did a search on google for cookies vs session but all I got was persistent cookies vs session cookies.
What is the pros/cons of having session cookies compared to using httpsession? If I recall my lecture today, the instructor stated that both session cookies and httpsession will be destroyed once the browser is closed. So what's the point of using session cookies when you could simply use httpsession. In terms of coding, it's easier to use httpsession and you can even store objects but with cookies, you can't.
__________________
Looking out the window, that's an act of war. Staring at my shoes, that's an act of war. Committing an act of war? Oh you better believe that's an act of war |
06-13-2005, 11:38 PM | #2 (permalink) |
Crazy
|
I've never once even bothered with session cookies. I have always used the HttpSession. However, cookies can come in handy if you are coding a feature like, "remember my password for 2 weeks," becuase you can set the expiration date on the cookie, which you obviously can't do with the Session. So, in some situations, like the one above, you may find it more desireable to use a cookie, otherwise I suggest trying to avoid them as much as humanly possible, and stick to sessions.
__________________
Solve two problems at once. Feed the homeless to the hungry. |
06-14-2005, 01:14 AM | #3 (permalink) |
Addict
|
cookies stay on the users computer for a specified time, thats how sites like this remember passwords, a session is limited to time the user is involved with the site. Use whatever is best for what you are trying to achieve, you can use both - it's not a case of one method or t'other.
|
Tags |
cookies, java, session |
|
|