Difference between Session and Cookie

There is some difference between a session and a cookie. Anyway both of them performs the same functionality of maintaining some user information. But in a different ways.


Session consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.


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.
Difference between Session and Cookie

* If you set the variable to “cookies”, then your user wont have to log in each time they enter into the portal.
* The cookie will be saved in a place within the user’s browser until it is deleted by the user.
* But Sessions are popularly used than cookies, as the there is a chance of your cookies getting blocked if the user browser security setting is set high.
* If you set the variable to “sessions”, then user activity will be tracked using browser sessions, and your users will have to log in each time they re-open their browser. Additionally, if you are using the “sessions” variable, you need to secure the “sessions” directory, either by placing it above the web root or by requesting that your web host make it a non-browsable directory.
* The Key difference would be cookies are stored in your hard disk whereas a session aren’t stored in your hard disk. Sessions are basically like tokens, which are generated at authentication. A session is available as long as the browser is opened.

By intrepidkarthi

I am Karthikeyan, working as a software professional, interested in Travelling, Bike riding, PC Gaming, Reading Novels, Blogging, Writing thamizh poems.

Leave a Reply

Your email address will not be published.