Re: cookies problem



On May 31, 7:42 pm, "Rik Wasmus" <luiheidsgoe...@xxxxxxxxxxx> wrote:
On Sat, 31 May 2008 20:16:44 +0200, oooobs <ooo...@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

thanks Rik ,it works
your second point solved the problem
i dont know how to thank you for your time
best regards
Ahmed
.



Relevant Pages

  • Re: cookies problem
    ... my problem is i cant register cookie ... i use this code to check cookie and seesion and it is included to all ... it is part of class user but because the class "user" ... var $username; ...
    (comp.lang.php)
  • Re: cookies problem
    ... my problem is i cant register cookie ... i use this code to check cookie and seesion and it is included to all ... it is part of class user but because the class "user" ... var $username; ...
    (comp.lang.php)
  • Re: cookies problem
    ... my problem is i cant register cookie ... i use this code to check cookie and seesion and it is included to all ... it is part of class user but because the class "user" ... var $username; ...
    (comp.lang.php)
  • Re: cookies problem
    ... my problem is i cant register cookie ... i use this code to check cookie and seesion and it is included to all ... it is part of class user but because the class "user" ... var $username; ...
    (comp.lang.php)
  • Re: Content of shared left border is showing up as 2 columns instead of 1
    ... I edit this website remotely directly on the ... The website has a Left Shared Border with a navigation bar and some text ... I edit the website directly on the remote server. ... var domainTo = 'durhambryans.com'; ...
    (microsoft.public.frontpage.client)