I want the main page of my site to recognize a returning user (like Amazon, etc.) without forcing them to re-login on every visit. There was a series of questions about this on the phplib mailing list earlier this year (look up "permanent session") but the answers seemed to require abandoning phplib, which I do not want to do.
I am using phplib to require login and authentication on the user preferences page (functionality like Amazon does with account preferences) but session data expires when the browser is closed and user-specific data, with or without a "nobody" default, requires login as the appropriate user.
Using modifed versions of the examples classes, I am trying to use cookies like this:
<?php page_open(array("sess" => "my_Session", "auth" => "my_Challenge_Crypt_Auth", "user" => "my_User"));
$expiredate = mktime(0,0,0,1,1,2004);
SetCookie("MyCookie", $auth->auth["uid"], $expiredate,"/",".mydomain.com");
-- rest of page printed from templates here---
page_close()
?>
The problem is that the cookie is not set when the user logs in. It does get set if the page is refreshed via a submit button. How can I set the cookie immediately after the log-in? Or is there a better way to do this?
Thank you very much.