Showing posts with label difference between PHP session and cookie. Show all posts
Showing posts with label difference between PHP session and cookie. Show all posts
Difference between Cookies and Session in PHP
Posted by Raj
Difference between Cookies and Session in PHP
- Cookies are stored in the user’s browser memory.A cookie can keep information in the user's browser until deleted.
- Session : logical object that allows you to preserve data across subsequent http requests.Whenever PHP creates a new session, it generates a session ID.
- Session values are store in server side not in user’s machine. A session is available as long as the browser is opened. User couldn't be disabled the session.
- Cookies are stored in client side and sessions are stored in server side.
- Cookies can only store strings.We could store not only strings but also objects in session.
- we could be save cookie for future reference, but session couldn't. When users close their browser, they also lost the session.