Joseph Witchard
05-06-2008, 10:32 PM
It's been awhile since I've worked with sessions in PHP. Could someone show me the complete syntax to initialize a session?
|
Click to See Complete Forum and Search --> : Session Syntax Joseph Witchard 05-06-2008, 10:32 PM It's been awhile since I've worked with sessions in PHP. Could someone show me the complete syntax to initialize a session? NogDog 05-06-2008, 10:56 PM OK. Bear with me now, it's going to take a lot of code to show you this. Ready? <?php session_start(); :D :p ;) Joseph Witchard 05-06-2008, 11:02 PM Haha. But when I did it that way a few months ago, I wasn't able to get it to work with just that. I had to use variables, and mark the variable as true, and a lot of different stuff like that. There's more you have to do to get it work than just that little bit, isn't there? NogDog 05-06-2008, 11:24 PM Assuming that there's nothing non-standard with your PHP/web-server configuration, that should be all you need to initialize a session. (Note that it needs to be in each script that will read/save session data, and must occur before any output of any kind is generated.) To save session data, just add it to the $_SESSION super-global array. To read it, just access the applicable element in that array. Unless there is something more complex you wish to do, that is all the basics of using sessions. See http://us.php.net/manual/en/book.session.php for all the info. Note, avoid the old-fashioned $HTTP_SESSION_VARS array (which is not super-global) and its related session_register(), session_unregister(), session_is_registered() functions. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |