#native_company# #native_desc#
#native_cta#

Session Management in PHP4

By Mattias Nilsson
on 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):

<?php

session_start();

$my_session_variable "some value";

session_register("my_session_variable");

?>



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.