rarebit Posted November 9, 2009 Share Posted November 9, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 9, 2009 Share Posted November 9, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-954214 Share on other sites More sharing options...
rarebit Posted November 9, 2009 Author Share Posted November 9, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-954225 Share on other sites More sharing options...
mentalist Posted November 11, 2009 Share Posted November 11, 2009 ive also just got this issue, a 'Undefined Index', but cookie is in firefox and opera, no access to it from php from google they say to wrap name in quotes, still no Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-955884 Share on other sites More sharing options...
oni-kun Posted November 12, 2009 Share Posted November 12, 2009 Check the physical contents of the cookie and what domain it is valid in, then look to your CMS page where it sets the cookie/logs in and check if it is the PROPER DOMAIN or SUBDOMAIN. Remember, "site.com" is not ".site.com". Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-955984 Share on other sites More sharing options...
mentalist Posted November 12, 2009 Share Posted November 12, 2009 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 ) what, where, when, who, why and how the blazes... Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-956281 Share on other sites More sharing options...
rarebit Posted November 13, 2009 Author Share Posted November 13, 2009 The _CMS_COOKIE_NAME reference is a defined variable. Also tried replacing all instances to both single and double quoted literal e.g. 'stayin'. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-956959 Share on other sites More sharing options...
rarebit Posted November 14, 2009 Author Share Posted November 14, 2009 Bump, oops Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-957382 Share on other sites More sharing options...
rarebit Posted November 14, 2009 Author Share Posted November 14, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/180880-solved-cookie-mystery/#findComment-957596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.