What is Session:-
A php Session variable is stored the single user information and are available all the page in the application.
A PHP session solves this problem by allowing you to store single user informations on the server at a time.session information is the temporary store on the server,you are left the site then will be deleted.
Session work on a unique ID because they are stored single unique value on the server.
Starting a php session-
<?php
start_session(); // session is start
?>
A simple Example describes below for using php session on a page-
A php Session variable is stored the single user information and are available all the page in the application.
A PHP session solves this problem by allowing you to store single user informations on the server at a time.session information is the temporary store on the server,you are left the site then will be deleted.
Session work on a unique ID because they are stored single unique value on the server.
Starting a php session-
<?php
start_session(); // session is start
?>
A simple Example describes below for using php session on a page-
session.php
<?php
session_start();
//session initialization
$_SESSION['view'] = 'rajendra'; // storing session (value rajendra) * view is session name this is optional if you want then change the name
?>
<?php
echo "welcome " . $_SESSION['view'] . "<br/>";
// print the session value welcome rajendra
?>
<?php
if(isset($_SESSION['view']))
{
echo "Session is set..."; // session have a value then session is set
}
else
{
echo "Session not set...";
}
?>
<?php
unset($_SESSION['view']); // unset the session value because session is logout
session_destroy(); // delete all information of the session called session_destroy
echo "session destroy...";
?>