By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,930 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,930 IT Pros & Developers. It's quick & easy.

cookies problem

P: n/a
Hello i have deficulty to deal with cookies in PHP
my website is http://kal.am
cookies not working and when i tried to print session array i got the
following strange output:

__utma 238121498.423365001.1211713664.1212127389.12121302 22.30
__utmz 238121498.1212127389.29.4.utmcsr=hffar.com|utmccn= (referral)|
utmcmd=referral|utmcct=/
__utmc 238121498
cprelogin no
cpsession closed
PHPSESSID a1db2915fffd55355c16a97e13741ccf
could you notice that line "utmcsr=hffar.com" it is refers to other
website(my old website)!!!!!!!!!!
if some one know how to chage this line "utmcsr=hffar.com" to refer to
my website www.kal.am it may solve the problem

Thanks for help
Ahmed
Jun 2 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Fri, 30 May 2008 20:10:55 +0200, oooobs <oo****@gmail.comwrote:
Hello i have deficulty to deal with cookies in PHP
my website is http://kal.am
cookies not working and when i tried to print session array i got the
following strange output:

__utma 238121498.423365001.1211713664.1212127389.12121302 22.30
__utmz 238121498.1212127389.29.4.utmcsr=hffar.com|utmccn= (referral)|
utmcmd=referral|utmcct=/
__utmc 238121498
cprelogin no
cpsession closed
PHPSESSID a1db2915fffd55355c16a97e13741ccf
could you notice that line "utmcsr=hffar.com" it is refers to other
website(my old website)!!!!!!!!!!
if some one know how to chage this line "utmcsr=hffar.com" to refer to
my website www.kal.am it may solve the problem
I don't know what your exact problem with the $COOKIE array is, however,
the __utmz cookie refers usually to Google Analytics, which I could not
find on your current site. You can find some details about that cookie @
http://www.codeproject.com/KB/script...Analytics.aspx Having that
hffar.com string in it should not cause any problems whatsoever

The only cookie I get set is this:
Set-Cookie: PHPSESSID=adf8479d9bd2b73320f1cbe39e8f2cc8; path=/;
domain=.kal.am

which seems perfectly OK to me.

Could you tell us more about the exact problem you're having, what you are
trying to do and where it fails?
--
Rik Wasmus
....spamrun finished
Jun 2 '08 #2

P: n/a
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
Jun 2 '08 #3

P: n/a
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
Jun 2 '08 #4

P: n/a
On May 30, 8:20 pm, oooobs <ooo...@gmail.comwrote:
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?
Jun 2 '08 #5

P: n/a
On Sat, 31 May 2008 20:16:44 +0200, oooobs <oo****@gmail.comwrote:
On May 30, 8:20 pm, oooobs <ooo...@gmail.comwrote:
>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
Jun 2 '08 #6

P: n/a
On May 31, 7:42 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Sat, 31 May 2008 20:16:44 +0200, oooobs <ooo...@gmail.comwrote:
On May 30, 8:20 pm, oooobs <ooo...@gmail.comwrote:
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
Jun 2 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.