Jump to content

sessions VS cookies


hassank1

Recommended Posts

Sessions: stored on the server

Cookies: stored on the client's machine.

 

If you would like people to remain logged in whever they come to your website, use cookies. Otherwise use sessions.

 

Sessions usually set a cookie however, to track the session ID. This can be parsed around in the URL though. As was mentioned, it's probably best you do some reading.

Link to comment
https://forums.phpfreaks.com/topic/99591-sessions-vs-cookies/#findComment-509513
Share on other sites

Indeed. The main security issue with sessions occurs when you allow the session ID to be passed around in the URL. What happens is that people may give someone else a link, not realising their session ID is in that link. The person that recieves the link then becomes logged in.

 

Hence why this option is generally disabled.

Link to comment
https://forums.phpfreaks.com/topic/99591-sessions-vs-cookies/#findComment-509576
Share on other sites

In short, both. This is the most secure way, in my opinion. Use sessions, but store the session ID in the cookie.

 

Session propagation through URL, as described above, has security risks. Storing session data in a cookie has its equally dangerous implications, if someone is able to steal the cookie.

 

So store the session data on the server however you choose, and keep track of session ID's to correspond to the data in their cookies.

 

Bryan

Link to comment
https://forums.phpfreaks.com/topic/99591-sessions-vs-cookies/#findComment-509639
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.