Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What information is OK to store in cookies?

Tags:

When thinking about security and user experience, what information id OK, acceptable, or even a good idea to store in a cookie?

EDIT:


With the understanding that sensitive info, like user names, passwords, SSN, credit card numbers don't belong there, what does?

like image 743
cdeszaq Avatar asked Apr 01 '09 18:04

cdeszaq


People also ask

What is safe to store in a cookie?

A common practice is to just store a session ID in a cookie, and store all other relevant information in a database (or file, or whatever) on the server, indexed by session ID.

Is it safe to store user data in cookie?

You can't trust any information stored in a cookie, as the user can manipulate it at his/her leisure. I suggest using a PHP session to store the object. That way, the end user only has a session ID stored in a cookie, with the real data on your server.

What type of information is collected by cookies?

Cookies are small pieces of text sent to your browser by a website you visit. They help that website remember information about your visit, which can both make it easier to visit the site again and make the site more useful to you.


1 Answers

Definitely not passwords! Or anything sensitive... remember that cookies are stored on people's computers so from your point of view (as a website developer), they're basically out in the wild, potentially accessible to anyone.

A common practice is to just store a session ID in a cookie, and store all other relevant information in a database (or file, or whatever) on the server, indexed by session ID.

like image 179
David Z Avatar answered Sep 22 '22 12:09

David Z