Re: cookies problem
- From: "Rik Wasmus" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Sat, 31 May 2008 20:42:30 +0200
On Sat, 31 May 2008 20:16:44 +0200, oooobs <oooobs@xxxxxxxxx> wrote:
On May 30, 8:20 pm, oooobs <ooo...@xxxxxxxxx> wrote:Hello Rik and thanks
my problem is i cant register cookie
i use this code to check cookie and seesion and it is included to all
pages of my website
note:$USER is an object which containt user data
if(isset($_SESSION['sessUSER'])){
$USER = unserialize($_SESSION['sessUSER']);}else{
if(isset($_COOKIE['cookieUSER'])){
$_SESSION['sessUSER'] = $_COOKIE["cookieUSER"];
$USER = unserialize($_COOKIE['cookieUSER']);
}else{
$USER = new USER();
session_register("sessUSER");
$_SESSION['sessUSER'] = serialize($USER);
unset($_SESSION['sessUSER']);
unset($_COOKIE['cookieUSER']);
}}
@@@@@@@@@@@@@@@@@@@@
and the code for registering the session is (FILE: USER.PHP)
note: it is part of class user but because the class "user"
class USER
{
var $id;
var $username;
var $password;
var $email;
var $usertype;
var $auth;
function USER(){}
function auth(){
global $USER;
return ($this->auth);
}
function login($username,$password,$remember_me = false){
global $CFG, $USER;
if(auth_user($username, $password)){
$USER = get_user_info($username);
$this->auth = "1";
$_SESSION['sessUSER'] = serialize($USER);
if($remember_me){
$Month = 2592000 + time();
setcookie("cookieUSER", $_SESSION['sessUSER'],
$Month,".kal.am");
}
return true;
}
else
{
$this->auth = "0";
$_SESSION['sessUSER'] = serialize($USER);
unset($_SESSION['sessUSER']);
unset($_COOKIE['cookieUSER']);
return false;
}
}
}
and this $USER->login method is called by page signin.php
the problem is when i try to get data from cookie i couldnt so thats
what made me think there is a problem with domain (before your replay)
Thanks alot if you solve this problem and thanks alot if you dont ( at
least you was kind to try)?
Ahmed
did anyone know how to solve this problem?
Hmmm, I could've swarn I'd answered it, must be still in the outbox at work. However, 2 points:
1) use session_start() everywhere.
2) alter:
setcookie('cookieUSER', $_SESSION['sessUSER'],$Month,'.kal.am');
to:
setcookie('cookieUSER', $_SESSION['sessUSER'],$Month,'/','.kal.am');
--
Rik Wasmus
....spamrun finished
.
- Follow-Ups:
- Re: cookies problem
- From: oooobs
- Re: cookies problem
- References:
- cookies problem
- From: oooobs
- Re: cookies problem
- From: Rik Wasmus
- Re: cookies problem
- From: oooobs
- Re: cookies problem
- From: oooobs
- cookies problem
- Prev by Date: Re: Looking for Open Source Partner
- Next by Date: Re: Looking for Open Source Partner
- Previous by thread: Re: cookies problem
- Next by thread: Re: cookies problem
- Index(es):
Relevant Pages
|