note 94944 modified in function.session-start by danbrown

From: Date: Thu, 03 Dec 2009 20:51:16 +0000
Subject: note 94944 modified in function.session-start by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163551@lists.php.net to get a copy of this message
I have found that you can use arrays with session variables in a very convenient manner. Be sure to unset the array afterwards! The following is an example. <?php session_start(); $sessionvars['name'] = "John"; $sessionvars['age'] = "43"; $sessionvars['gender'] = "Male"; $sessionvars['email'] = "john.doe@example.com"; $_SESSION['arvars'] = $sessionvars; unset($sessionvars); echo $_SESSION['arvars']['name']."<br>"; echo $_SESSION['arvars']['age']."<br>"; echo $_SESSION['arvars']['gender']."<br>"; echo $_SESSION['arvars']['email']."<br>"; ?> --was-- I have found that you can use arrays with session variables in a very convenient manner. Be sure to unset the array afterwards! The following is an example. <?php session_start(); $sessionvars['name'] = "John"; $sessionvars['age'] = "43"; $sessionvars['gender'] = "Male"; $sessionvars['email'] = "jdoe3@gmail.com"; $_SESSION['arvars'] = $sessionvars; unset($sessionvars); echo $_SESSION['arvars']['name']."<br>"; echo $_SESSION['arvars']['age']."<br>"; echo $_SESSION['arvars']['gender']."<br>"; echo $_SESSION['arvars']['email']."<br>"; ?> http://php.net/manual/en/function.session-start.php

« previous php.notes (#163551) next »