// Make a file index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// begin the session
session_start();
// set the value of the session variable 'foo'
$_SESSION['username']='Mandeep Deol';
$_SESSION['Password']='Password';
// echo a little message to say it is done
echo 'Setting Value of Username & Password';
?>
</body>
</html>
// Make a file 2.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// begin our session
session_start();
// echo the session variable
echo 'Username is '.$_SESSION['username']."<br>";
echo 'Password is '.$_SESSION['Password'];
?>
</body>
</html>
// Make a file distroy.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// Begin the session
session_start();
// Unset all of the session variables.
session_unset();
// Destroy the session.
session_destroy();
echo "Destroy Session Completely.";
?>
</body>
</html>
1 comment:
Session variables hold information about one single user, and are available to all pages in one application...this concept is wonderful sir...
Post a Comment