Thursday, 13 October 2016

get and set session in php

Example set session 

<?php

session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php

$_SESSION["favcolor"] = "green";
echo "Session variables are set.";
?>

Example get session 

<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php

echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";

?>

No comments:

Post a Comment