Skip to content

PHP code snippet – How to make a variable available in another file?


   $_SESSION['superhero'] = "batman";

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

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

See also  PHP code snippet - How upload image in arraye in laravel?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.