+ 5
What are the advantages of cookies and sessions in PHP?
4 ответов
+ 3
thank you
+ 3
It's easier to eat all of the cookies if we split it up into sessions. :)
Sorry... I'm corny, I know.
COOKIES - stores data inside of files on the client machine that can be retrieved later by the websites. This is great for storing things like configuration/preferences, remember login information to autopopulate, etc.. etc.. etc.. Good rule of thumb - DON'T STORE PASSWORDS OR ANY CRITICAL PERSONAL INFORMATION INSIDE COOKIES. Why? Cookies are stored on a local machine so it's very easy to access the information contained inside of them.
SESSION - Similar to a cookie in that it's holding onto data for you to utilize on your website, it's also stored on the local end BUT it's stored as part of the browser's process. What does this mean? That information goes bye-bye the moment that you close the browser and it isn't stored in a file on the operating system. This is good for storing temporary login information/status and pretty much anything that you want to store but want to have wiped when the browser closes.
******
Critical or personal information ideally should be stored on your database because it's secured behind your server and code.
+ 2
You're welcome! Best of luck.
+ 1
you can do all by session but usually use then for auth!