Jump to content

Recommended Posts

Hi

 

I wrote some code a while back for my cms, it basically used a single cookie to function as a stay logged in system. All worked well for ages.

 

I noticed recently that something was wrong and you weren't staying logged in. Upon further investigation it seems the cookie isn't being caught by httpd / php, basically it's not in the $_COOKIES array (or in $HTTP_COOKIE_VARS array, and not there when using print_r).

 

I've wrapped the setcookie function call with try's, no issue. And if I look in FF properties I can see the cookie in question (even delete it and set it with different data using afore-mentioned call).

 

So why can't I access or see the cookie?

 

 

 

:o

Link to comment
https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/
Share on other sites

Browsers only send cookies that match the requested URL. Any chance that the cookie path or cookie domain setting has been changed or that the actual path or domain where the script is being executed at no longer matches the path or domain being set for the cookie?

The cms use's url rewrite and is set using the root of the cms on the server. However i'm pretty sure the htaccess code hasn't altered, even though I did have a glance at it. Also it does indicate said path in FF properties.

 

 

 

P.S. I'm currently having to duel boot because of wpa issues... so i'm intermittant...

ok, me bein im elsewhere...  :'(

 

cookie particulars:

host: 10.0.0.55
path: http://10.0.0.55/cmstmp/onebigsofa/cmsmonkey.0.4.1/

typical page calls... (mod rewrite always passes to index?).

http://10.0.0.55/cmstmp/onebigsofa/cmsmonkey.0.4.1/
http://10.0.0.55/cmstmp/onebigsofa/cmsmonkey.0.4.1/index?feedback=Welcome%20back
http://10.0.0.55/cmstmp/onebigsofa/cmsmonkey.0.4.1/index.phtml
http://10.0.0.55/cmstmp/onebigsofa/cmsmonkey.0.4.1/site/special.html

 

 

a typical use of setcookie:

setcookie(_CMS_COOKIE_NAME,'012',time()+31536000,$site_data['site_addr'].$site_data['dir_path']);

 

 

 

in the debug bit...

This code...

$sret .= $_COOKIE[_CMS_COOKIE_NAME]."<br />\n";
//$sret .= $HTTP_COOKIE_VARS[_CMS_COOKIE_NAME]."<br />\n";
print_r($_COOKIE);	// Print all cookies

yeilds:

Notice: Undefined index: stayin in /var/www/html/cmstmp/onebigsofa/cmsmonkey.0.4.1/monkey/debug.php on line 60
Array ( [phpSESSID] => g59u7239lh9046v5ca0v44smu2 )

 

 

 

:shrug: what, where, when, who, why and how the blazes...

 

mmm, so if anyone saw this in my previous post:

host: 10.0.0.55
path: http://10.0.0.55/cmstmp/onebigsofa/cmsmonkey.0.4.1/

 

you may have noticed that that's not how you specify a path...

path: /cmstmp/onebigsofa/cmsmonkey.0.4.1/

 

At least i've learnt something today which I won't forget...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.