SESSION
Data is stored on the server. This can be used to move data from one page to another across the website.
Example
When a user logs in to the website, we store user’s id in a session. This way we can check at any page that who has logged in and we can destroy session once user logs out.
To start a session
session_start();
To store data in session
$_SESSION[“variablename”] = “value”;
Basic difference between session and cookies is
Session data is stored on server while cookies data is saved on client’s browser.
Sessions are more secure than cookies.
Leave a comment