how to store session value in variable in php code example
Example 1: set php varibianle session
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
$_SESSION["color"]= "blue";
$_SESSION["animal"]= "dog";
echo "The session variable are set up.";
?>
</body>
</html>
Example 2: php session destroy
<?php
session_destroy();
?>
Example 3: php session variables
<?php
session_start();
$_SESSION['var'];
?>
Example 4: getting input value in session variable in php
$qty = isset($_GET['qty']) ? $_GET['qty'] : 1;
$_SESSION['qty'] = $qty;
Example 5: can we acces session variable in two files
<?php
session_start();
...
if($responseCode == 1) {
$_SESSION['card_id'] = $_POST['card_id'];
$_SESSION['password'] = $_POST['password'];
print '<script type="text/javascript">';
print 'window.location = "http://domain.com/File2.php";';
print '</script>';
}
?>