What is SESSION and COOKIE? ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is SESSION and COOKIE? ?

explain about session and cookies difference?

29th Mar 2018, 10:13 AM
Selva kumar M
Selva kumar M - avatar
3 Answers
+ 6
What is a PHP Session? When you work with an application, you open it, do some changes, and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web server does not know who you are or what you do, because the HTTP address doesn't maintain state. Session variables solve this problem by storing user information to be used across multiple pages (e.g. username, favorite color, etc). By default, session variables last until the user closes the browser. So; Session variables hold information about one single user, and are available to all pages in one application. Tip: If you need a permanent storage, you may want to store the data in a database. A cookie is often used to identify a user. What is a Cookie? A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.
29th Mar 2018, 11:26 AM
Baraa AB
Baraa AB - avatar
+ 3
Hi, Well, a cookie is data that is saved on the users computer while session is stored at the server AND ONLY available for as long that users session is alive. The data can be almost anything. That is a short description of the differences.
29th Mar 2018, 10:41 AM
Jan B. Michanek
Jan B. Michanek - avatar
0
vietnam
31st Mar 2018, 1:33 AM
Hồ Hoangthai
Hồ Hoangthai - avatar