Jump to content

[SOLVED] COOKIE or SESSION?


Northern Flame

Recommended Posts

If you can, I'd use sessions.  Sessions are far more secure than using cookies.  Cookies are for more permanent data, but are stored on the client-side.  Where sessions are global variables while the window is open and stored on the server-side which makes them more secure.

You can store whatever you like, as long as you feel comfortable with what you are checking when they come back.  It can be anything, even a code.  Usually its just 1 or 2 items, since once they are on your site, you can check their info in the DB for updated info.

 

Like if you were to store their Admin level in a cookie, what happens when you put them down to a normal user, if their cookie always says Admin, then they can get to places they shouldn't after you remove that access.

Use both, I would say.  Sessions are most commonly used with cookie's in combination.  The session is the data stored on the server and the cookie is stored on the user's machine.  Only by recieving the "matching" cookie to go with the session does session work.  You can use sessions on their own and pass the data via the url but that comes with it's own set of security problems.

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.