PHPBuilder - Session Management in PHP4

RSS Twitter

Session Management in PHP4

by: Mattias Nilsson
July 30, 2000

After my last article about Session Management in PHP4, I got several emails from people that had problems implementing what I tried to describe. All theese emails had the same question:
Can you give me example code ? Yes, sure I can.
I will assume that you have read my previous article ( it's here in case you missed it). As I described earlier, you have to tell PHP that the current page use session variables by calling the session_start() function. Once this function is called, you are free to register any variable that you have bound as a session variable. This is done using the session_register() function.
The first example (page1.php):


$my_session_variable "some value";

What this does is that it registers the variable my_session_variable as a session variable. This means that the variable will be alive (keep it's value) across page-accesses, as long as you call the session_start() function on all pages that need access to the my_session_variable variable.

Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Mattias Nilsson



(Maximum characters: 1200). You have characters left.