0% found this document useful (0 votes)
7 views5 pages

Lec 17 PHP

Session variables allow information to be stored and retrieved across multiple pages and are used to maintain state about a single user. To use session variables, the session_start() function must be called before any other output and sessions must be started before storing or accessing data. Session data is stored in the $_SESSION superglobal array and can be unset or destroyed to remove it.

Uploaded by

Iram Mujawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Lec 17 PHP

Session variables allow information to be stored and retrieved across multiple pages and are used to maintain state about a single user. To use session variables, the session_start() function must be called before any other output and sessions must be started before storing or accessing data. Session data is stored in the $_SESSION superglobal array and can be unset or destroyed to remove it.

Uploaded by

Iram Mujawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 5

PHP Sessions

 A PHP session variable is used to store


information about, or change settings for a
user session.
 Session variables hold information about one
single user, and
 are available to all pages in one application.
PHP Sessions

 session_start()
 Before you can store user information in your
PHP session, you must first start up the
session.

 The session_start() function must appear


BEFORE the <html> tag
PHP Sessions

 $_SESSION['views']=1;

 if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
PHP Sessions

 unset($_SESSION['views']);
 The unset() function is used to free the
specified session variable
 session_destroy();
 session_destroy() will reset your session and
you will lose all your stored session data.

You might also like