PHP Sessions

By | January 1, 2014

Session variable stores the information about a user that variable will be availbale to all pages and we can handle the login track using the session concept

Session is time duration when the user start to browse a webpage and it will be live until the page close.

in php we will use the ‘session_start();’ function at the begining of a php page

for example

$_SESSION[‘mydoubts’]=’somevalue’;

in each page we can check the session is set or not using the below script

if(isset($_SESSION[‘mydoubts’]))

{

// shows the page you want to display
}

else

{

// redirect home page.

}

For destorying the session

session_destroy()