Sessions Step By Step
-
Defining session before everything, No output should be before that, NO OUTPUT
<?php session_start(); ?>
-
Set your session inside a page and then you have access in that page. For example this is page 1.php
<?php //This is page 1 and then we will use session that defined from this page: session_start(); $_SESSION['email']='[email protected]'; ?>
-
Using and Getting session in 2.php
<?php //In this page I am going to use session: session_start(); if($_SESSION['email']){ echo 'Your Email Is Here! :) '; } ?>
NOTE: Comments don’t have output.