PHP session Tutorial - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript PHP session Tutorial - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Monday, March 27, 2017

PHP session Tutorial


PHP SESSION Tutorial




In this tutorial i exaplain how to use session in php to get value in other page.

session is a way to get value in multiple pages without passing value from one page to another.

Let Start

Filename:- form.php
<html>
<head></head>
<body>
<form action=”show.php” method=”post”>
<label>User</label>
<br>
<input type=”text”name=”user”>
<br>
<input type=”submit” value=”submit”>
<!--here it was just an html form to transfer value to one page to other-->
</form>
</html>


Filename :-show.php
<?php
session_start();

//To use session we must start our session.session_start() is used to start our session.

$user=$_REQUEST[‘user’];
$_SESSION[‘user’]=$user;

//Set value in $_SESSION variable with key user now we get value from session in any page by session.

echo “Hello ”.$user;
echo “<br>”;
echo “<a href=’session.php’>Go To Next Page</a>


?>

Filename:- session.php
<?php
session_start();

//Again started session to get the value from session variable.

echo “Again Hello ”.$_SESSION[‘user’];

//here we accessing the session variable value which we set in show.php

echo “<a href=’destroy.php’>Do You Want To Destroy Session</a>”;

//session destroying link
?>

Filename :-destroy.php

<?php
session_start();
session_destroy();
//here we destroy session by session destroy.
?>


Thank you in next Tutorial i will share how to create a login system.

8 comments:

  1. Well done...!!! try to do more and update same way..
    Wed development services

    ReplyDelete
  2. We are already on Progress updating more post soon.

    ReplyDelete
    Replies
    1. Hi
      Nice post and thanks for gathering good information.
      https://goo.gl/sbjnH7

      Delete
  3. This post is nice. I find web designing service in Nagpur is best option for web development and designing.

    ReplyDelete
  4. Your blog is really up to the mark and there are some great facts there. So thanks for this really nice post.Website Designing Company in Delhi

    ReplyDelete
  5. Thanks for sharing such informative blog. Keep posting information rich content like this. Web Designing Company In Phoenix Arizona Az

    ReplyDelete

Post Top Ad