note 26462 deleted from function.session-name by philip
| From: | philip@php.net | Date: | Thu, 29 May 2003 15:52:43 +0000 |
| Subject: | note 26462 deleted from function.session-name by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-49254@lists.php.net to get a copy of this message | ||
Note Submitter: goten at nospam dot squad-wars dot com
----
The easy way to do the session registration and value setting is just to do this:
session_start();
session_register("session_variable");
$session_variable = "value";
Note that this method requires global variables to be enabled to work correctly, but if it
isn't then you'll have to do it the old fashioned way.
Thsi method is also very handy if you're getting lots of data from a database and don't
want to have to register and use $HTTP_SESSION_VARS all the time.
session_start();
session_register("session_var");
$query = mysql_query("SELECT * FROM table WHERE field='value'");
$data = mysql_fetch_array($query, MYSQL_BOTH) or die("error");
$session_var = $data["var"];
I'm not sure if this method is optimised or not, but it works for me (slightly differently, but
still).