Answers for "php how to make a variable available in another file"

PHP
0

php how to make a variable available in another file

//page1.php
<?php

   session_start();
   $_SESSION['superhero'] = "batman";

?>
<a href="page2.php" title="">Go to the other page</a>
  
//page2.php
<?php 

   session_start(); // this NEEDS TO BE AT THE TOP of the page before any output etc
   echo $_SESSION['superhero'];

?>
Posted by: Guest on September-12-2021

Code answers related to "php how to make a variable available in another file"

Browse Popular Code Answers by Language