Lab #4

5. Write two different PHP scripts to demonstrate passing variables with sessions

first.php

<?php
if(session_start()){
echo "Session start";
}
$_SESSION['name'] = "Bruce banner";
$_SESSION['hero_name'] = "Hulk";
?>

second.php

<?php
session_start();
echo "Session access <br/> <br/>";

if(isset($_SESSION['name']) && isset($_SESSION['hero_name'])){
echo "Name: ".$_SESSION['name']."<br/>";
echo "Hero Name: ".$_SESSION['hero_name']."<br/>";
}
?>

Output

first page

second page

Happy Coding :)