Fri, 17 May 2024


How to create a SESSION variable?

By: Nathalie, NetArt Media
Wed, 19 August 2020

The sessions in PHP are very useful to pass data through the pages, (as http is stateless protocol). At every session is associated a unique session ID which can be stored on a user's computer or in a cookie or passed along through a URL.

<?php
session_start(); // must be called before anything is output to the browser

$userEmail = "whatever@whatever.com";

$_SESSION["userEmail"] = $userEmail;

...

?>


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox