Sessions is an object which is used to store single OR multiple values in form of array OR string OR an object. These values are maintained/stored when you navigate one more more pages. Normal variable destroy automatically when you navigate the pages.
Difference between Session variable and Normal variable.
How to Create Session variable
How to Destroy session variable
Difference between Session variable and Normal variable.
Normal variable | Session variable |
Destroy when refresh the page | value are maintain when refresh the page |
Store in Memory | Store in cookie |
Stored location cannot be change | Location can be changed |
-NA- | In Login/Logout functionalities use session |
You can declare/use any where in php pages | Need to start session befor use the session use session_start() to start the session |
variable deleted automatically when out of scope | Session need to delete manually. Session delete automatically when it expire. |
delete automatically when out of scope | use "session_destroy()" to destroy |
How to Create Session variable
session_start(); //use only once in whole website /** create variable **/ $_SESSION['count']=1; /** use variable **/ $count = $_SESSION['count'];
How to Destroy session variable
unset($_SESSION['count']);
No comments:
Post a Comment