What are the advantages of cookies and sessions in PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

What are the advantages of cookies and sessions in PHP?

15th Feb 2018, 7:09 PM
Aranganathan S
4 Answers
+ 3
thank you
15th Feb 2018, 7:25 PM
Aranganathan S
+ 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.
15th Feb 2018, 7:25 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 2
You're welcome! Best of luck.
15th Feb 2018, 7:26 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
you can do all by session but usually use then for auth!
16th Feb 2018, 5:48 PM
Amirhosein Morteza
Amirhosein Morteza - avatar