faqts : Computers : Programming : Languages : PHP : Common Problems : Sessions and State

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

110 of 142 people (77%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How can I keep session variables?
Can I see a quick example of sessions in PHP4?

Feb 23rd, 2002 11:03
Philip Olson, Nathan Wallace, Soren Staun-Pedersen


1. PHP4 has native session functions, see:
   http://www.php.net/sessions
2. session_start(); before anything else on all your pages. (This can be
   done via a feature in php.ini to always start sessions)
   http://www.php.net/session_start
3. $foo = "i want to remember this"; 
   session_register("foo");
   http://www.php.net/session_register
$foo is now remembered on all your pages, and can be referred to in all
your functions via global $foo;
For basic session tutorials, read this faqt:
  http://www.faqts.com/knowledge_base/view.phtml/aid/6621/fid/8