jcadima
5/13/2015 - 9:06 PM

PHP SESSION

PHP SESSION

<?php
/*
 We’ve declared an array called userinfo and stored information inside it, 
 like the login name, if the user is currently logged in or not and finally 
 the UID. You can declare a normal array and then declare it as a $_SESSION variable later
*/
$userinfo = array( );
$userinfo['username'] = 'currentusername';
$userinfo['isloggedin'] = false;
$userinfo['UID'] = 1;
$_SESSION['userinfo'] = $userinfo;


/*
Here’s another way you could have declared the same array:
*/

$_SESSION['userinfo']['username']  = 'currentusername';
$_SESSION['userinfo']['isloggedin']  = false;
$_SESSION['userinfo']['UID']   = 1;