|
|
|
Yes, we get this question quite often. The problem here is that there are
many different ways to implement a session tracking system. Some people
use cookies. Others use a GET method argument added to each URL. Still
others use standard HTTP authentication, and you could also use hidden POST
method fields that you pass from page to page.
PHP provides all the tools to do any of these. Up to now we have left the
implementation up to the users.
For version 3.1 we are looking at ways to use shared memory somehow to
make it possible to have persistent variables in PHP, but overtop of that
you still need a session identifier so you know who is allowed to go and
fetch these persistent objects. Exact implementation is still up in the
air.
I think the two common method in use today is the simple cookie
session mechanism. Use the uniqid() PHP function to create a unique
session key and the use PHP's SetCookie() function to send this to the
remote browser. For example:
if(!isset($session)) {
$session = uniqid("sess");
SetCookie("session",$session); /* you may want more options here */
}
Now, the $session variable will be available on every page. You can back this
with a database and store information about each session there.
The alternative is to embed this $session variable in each link. Something
like: <a href="whatever.html?session=<?echo $session?>">Link</a>
Then again, $session will automatically be avilable on each page.
|
|
| Simple script to passing persistent and growing array between recalls of one page (manipulate little stack). Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables | | | Basic Authentication with sessions Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions | | | Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts. Categories : HTML, Variables, Debugging, PHP, HTTP | | | The following snippet gives complete info about all submitted
HTTP_POST_VARS and HTTP_GET_VARS Categories : Variables, HTTP, PHP | | | PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions | | | How to display a PHP variable value from a selectbox without reloading the
page by merging PHP and Javascript variables. Categories : PHP, Java Script, Variables | | | Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
Categories : PHP, Directories, Variables, Arrays | | | translate.php - Assocciative array example, passing a reference to a function. Categories : PHP, Arrays, Languages, Variables | | | Security, Password lock out after three tries, authorization fails and is logged locked out of account till admin decides he will unlock it. Categories : Sessions, PHP, MySQL, PHP Options and Info | | | getting the name of the current script and query string Categories : PHP, Global Variables, Variables, URLs | | | clearing variables in php3 Categories : Variables, Arrays, PHP | | | Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | Demo of Alternate Pagination Paradigm (Paging) Categories : PHP, User Interface, Sessions | | | XDT Topsite (Gold v1.0) Categories : Databases, CSS, PHP, HTML and PHP, Sessions | | | A simple function to prevent undefined $_POST/$_GET/$_SESSION variable errors Categories : PHP, Variables, Errors and Logging | |
|
|
|