PHP session start (Set) Destroy Update and View
PHP Session start (Set) Destroy Update and View
PHP session starts, Destroy, Update, and View is the topic of discussion for today. Let’s begin with Creating the session. We need to create four files.
- session_set.php
- session_vie.php
- session_destroy.php
- session_modify.php
PHP Session set
session_set.php
1 2 3 4 5 6 7 8 |
<?php session_start(); ?> <?php $_SESSION["password"] = "t4tutorials"; echo "Session variables are set."; ?> |
PHP Session View
session_view.php
1 2 3 4 5 6 7 8 |
<?php session_start(); ?> <?php // Echo session variables that were set on previous page echo "Email is " . $_SESSION["email"] . ".<br>"; echo "Password is " .
$_SESSION["password"] . "."; ?> |
PHP Session destroy
session_destroy.php
1 2 3 4 5 6 7 8 9 |
<?php session_start(); ?> <?php // this will remove all session variables session_unset(); // this will destroy the complete session session_destroy(); ?> |
PHP Session Modify
session_modify.php
1 2 3 4 5 6 7 8 |
<?php session_start(); ?> <?php // this will change a session variable print_r($_SESSION); ?> |