Sunday, 10 February 2019

Session to store Data Through Complete Website

Account.html:


<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="session.php">
user name:<input type="text" name="username"></br></br>

password:<input type="password" name="password"></br></br>

<input type="submit" value="Register" name="">

</form>
</body>
</html>

session.php



<?php
session_start();
$_SESSION['username']=$_POST['username'];
$_SESSION['password']=$_POST['password'];
echo $_SESSION['username'];
echo $_SESSION['password'];
?>


View1.php

<?php
session_start();
echo $_SESSION['username'];
echo $_SESSION['password'];

?>


unset.php


<?php
session_start();
unset($_SESSION['username']);
echo $_SESSION['username'];
echo $_SESSION['password'];

?>

checkoutput and refesh the browser and check the ouput again 

View2.php

<?php
session_start();
echo $_SESSION['username'];
echo $_SESSION['password'];

?>


check output 


next 


close the browser and see the View1.php output



to Destory all

Destory.php


<?php
session_start();
session_destroy();


?>

No comments:

Post a Comment