Session Management is not just for authentication purposes though, it can
even be used without authentication at all. You may use it to store any
information you want, and this information will be
available to all other pages the user visits which you have enabled with
phplib session management. To use it, you simply register the variable you
want to become persistent to other pages. This is done with a simple call
like:
even be used without authentication at all. You may use it to store any
information you want, and this information will be
available to all other pages the user visits which you have enabled with
phplib session management. To use it, you simply register the variable you
want to become persistent to other pages. This is done with a simple call
like:
<?php $sess->register("variable_name"); ?>
Note that you do not use the
the name of the variable you want to register. This is because when you
register a variable, you are making that variable (as in the variable name)
persistent, NOT the contents of that variable (it’s value). Thus, if you change
the value of a persistent variable on subsequent pages,
the value of the session variable will change as well.That’s all! That variable
(be it a string, number, array, even an object) will be available to you
on all further session pages. For example, let’s say
user info from a form. Let’s say it get’s the variable $firstname. You can
then do:
$variable
notation, simply a string containingthe name of the variable you want to register. This is because when you
register a variable, you are making that variable (as in the variable name)
persistent, NOT the contents of that variable (it’s value). Thus, if you change
the value of a persistent variable on subsequent pages,
the value of the session variable will change as well.That’s all! That variable
(be it a string, number, array, even an object) will be available to you
on all further session pages. For example, let’s say
page1.php3
is passed someuser info from a form. Let’s say it get’s the variable $firstname. You can
then do:
<?php
$sess
->register("first");
if (check($firstname)) {
$first = $firstname;
}
?>