|
Posted by Arjen on 02/18/06 16:13
Hi, I have the strangest problem.
Ive written a simple login script which logs in a user. It sets a
username and a unique id. Nothing wrong there but I seem to have some
troubles with overwriting my cookies; sometimes users cant logout and
sometimes users cant login. If I check the info that is written in the
cookie php stil reeds an old cookie wich should have been replaced
either with a login_id or a guest_id
Here are some parts of my code. got any ideas ??
login.php
// set the value
$cookieval= "$login->user[id]:$login->user[generated_uid]";
// set the cookie
SetCookie ("bezoeker", $cookieval, time()+31536000,"/");
checkuser.php
// select user info -> returns and array or bool false
// if no user is set the get a guest id
if (!$user = $myql->select_one($sql))
{
// $user = false -> create guest id
$guest_id=md5(uniqid(microtime(),1));;
// set the value
$cookieval= "gast:$guest_id";
// set the cookie
SetCookie ("bezoeker", $cookieval, time()+31536000,"/");
// set guest info
$user[naam]="gast";
$user[wachtwoord]=$row[wachtwoord];
}
logout.php
// this script doesn't really logout users, it just marks them as guests
$guest_id=md5(uniqid(microtime(),1));;
// set the value
$cookieval= "gast:$guest_id";
// set the cookie
SetCookie ("bezoeker", $cookieval, time()+31536000,"/");
Navigation:
[Reply to this message]
|