Re: maintaining [user] state without a session ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
It depends what do you need to track,
if you need to track small amount of variables you can do it by cookie
I often use it eg here is the state for one user
$state = array{
'logedin'=>true,
'n'=>'Peter',
'id'=>'5',
//anything else you need
}

//at end of you script before outputing any content
//set cookie only for browser session and set path to '/' so it is available through whole site
setcookie('user_data',serialize($state),null,'/');


At the begining of a script

$state = isset($_GET['user_data']) ? $_GET['user_data'] : null;

if( ! $state ) {
//user doesnt support cookies or this is a search engine set default $params
$state = array{
'logedin'=>false,
'n'=>null,
'id'=>null,
//anything else you need
}
}



Also you can use some way to detect if the user is not Search engine to display message like "To properly use this site you need to enable cookies in your browser bla bla ...."

This can be done via JS alert message which will not be triggered by SE but only by real user



On Mar 4, 2008, at 2:57 PM, Jochem Maas wrote:

hi people, hi Stut!

Stut mentioned a little while back that he avoids using the built- in session mechanism if at all possible, but still manages to track user state ... now I
can think of a way or two that he might do that but I was wondering if
any one could give an idea about the write way to do it in terms of
high performance :-)

tia,
Jochem

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Bojan Tesanovic
http://www.classicio.com/





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux