JCS1988 Posted February 10, 2008 Share Posted February 10, 2008 Hi, I am trying to set a cookie but it only ever shows up if I am using IE6. Is there something I'm missing? Thanks in advance. setcookie("currentcustomer", $customer_id, time()+3600*24); Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/ Share on other sites More sharing options...
Northern Flame Posted February 10, 2008 Share Posted February 10, 2008 try setcookie("currentcustomer", $customer_id, time()+3600*24, '/', 'www.yourwebsite.com'); Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463186 Share on other sites More sharing options...
JCS1988 Posted February 10, 2008 Author Share Posted February 10, 2008 Thanks for the reply. I tried that but I get a syntax error. Parse error: syntax error, unexpected ',' in /whs2fs1_2us4_2/jcs5325aii/domains/jcs5325.aisites.com/public_html/member-index.php on line 6 The modified code: <?php session_start(); require_once('auth.php'); $customer_id = $_SESSION['SESS_CUSTOMER_ID']; setcookie("currentcustomer", $customer_id, time()+3600*24), '/', 'www.jcs5325.aisites.com'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463316 Share on other sites More sharing options...
Aureole Posted February 10, 2008 Share Posted February 10, 2008 setcookie("currentcustomer", $customer_id, time()+3600*24), '/', 'www.jcs5325.aisites.com'; The part in red is your problem. Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463340 Share on other sites More sharing options...
JCS1988 Posted February 10, 2008 Author Share Posted February 10, 2008 Removing the ")" gives me an error. Parse error: syntax error, unexpected ';' in /whs2fs1_2us4_2/jcs5325aii/domains/jcs5325.aisites.com/public_html/member-index.php on line 6 This is what I have <?php session_start(); require_once('auth.php'); $customer_id = $_SESSION['SESS_CUSTOMER_ID']; setcookie("currentcustomer", $customer_id, time()+3600*24, '/', 'www.jcs5325.aisites.com'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463350 Share on other sites More sharing options...
Aureole Posted February 10, 2008 Share Posted February 10, 2008 I didn't say remove it, I said it's causing the problem... setcookie("currentcustomer", $customer_id, time()+3600*24, '/', 'www.jcs5325.aisites.com'; That's with it removed, do you see anything wrong? Maybe a mising ")" before the semi-colon? The error even tells you the problem... unexpected ';'... that means there's something missing before the semi-colon. Geez. Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463354 Share on other sites More sharing options...
JCS1988 Posted February 10, 2008 Author Share Posted February 10, 2008 so ")" being the problem, whats the solution to the problem? What has to be done for this to work correctly? Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463355 Share on other sites More sharing options...
Aureole Posted February 10, 2008 Share Posted February 10, 2008 That's with it removed, do you see anything wrong? Maybe a mising ")" before the semi-colon? The error even tells you the problem... unexpected ';'... that means there's something missing before the semi-colon. Geez. It's staring you in the face... Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463356 Share on other sites More sharing options...
JCS1988 Posted February 10, 2008 Author Share Posted February 10, 2008 I fixed it but it would only work in IE still. I just got rid of the set cookie and instead used a session that works in both browsers. Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463377 Share on other sites More sharing options...
Aureole Posted February 11, 2008 Share Posted February 11, 2008 Check your Firefox Cookie settings. Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463910 Share on other sites More sharing options...
aschk Posted February 11, 2008 Share Posted February 11, 2008 I would say this is a browser issue rather than a code issue. However isn't setcookie() deprecated now? I thought the new syntax was $_COOKIE['name of cookie'] = "value"; Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463913 Share on other sites More sharing options...
Aureole Posted February 11, 2008 Share Posted February 11, 2008 I just found this on PHP.net: If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie. That's interesting to note... also it isn't deprecated. Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463917 Share on other sites More sharing options...
aschk Posted February 11, 2008 Share Posted February 11, 2008 Thanks for checking that. Feeling a bit too lazy today to check it myself. setcookie for settings cookies $_COOKIE for retrieving cookies. Good pickup on the setcookie returning false if output has occured already. One to keep an eye out for now... Quote Link to comment https://forums.phpfreaks.com/topic/90338-cannot-set-cookies-in-firefox-only-in-ie/#findComment-463954 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.