You are here: Home » PHP » Session in PHP

Session in PHP

21 Flares 21 Flares ×

Session is an information which created by server and stored at the server. To start session, use session_start() function at the top of the page,


<?php session_start(); ?>

To store value in session,

<?php
session_start();
 $_SESSION['id']=1;
?> 

$_SESSION[‘id’]; srore value 1 until session not destroy. When ever we use $_SESSION[‘id’]; it’s result always be 1.

Destroy session value,

<?php
session_start();
session_destroy();
?> 

We can also use session_unset(); To free all session variables.

About Abhishek Sinha

I am Abhishek and I love to code on PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Scroll To Top
21 Flares Twitter 3 Facebook 2 Google+ 13 StumbleUpon 1 Pin It Share 0 LinkedIn 2 21 Flares ×