note 26462 added to function.session-name
| From: | goten at rack1 dot php dot net | Date: | Thu, 31 Oct 2002 13:55:03 +0000 |
| Subject: | note 26462 added to function.session-name | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38828@lists.php.net to get a copy of this message | ||
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).
--
http://www.php.net/manual/en/function.session-name.php
http://master.php.net/manage/user-notes.php?action=edit+26462
http://master.php.net/manage/user-notes.php?action=delete+26462
http://master.php.net/manage/user-notes.php?action=reject+26462