![]() |
[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. |
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.
|
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.
|
All times are GMT -8. The time now is 09:52 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project