dagnasty Posted September 27, 2006 Share Posted September 27, 2006 According to php.net this is supposed to work correctly setcookie("cookie", $value, time()+31556926, "/", ".website.com", 1);but doesn't, however this does:setcookie("cookie", $value, time()+31556926);The problem is that I need to set cookies for several domains. What's up with it? I don't seem to be missing anything. Quote Link to comment Share on other sites More sharing options...
Fehnris Posted September 27, 2006 Share Posted September 27, 2006 If you mean subdomains i.e www.example.com, example.example.com then by not specifying the domain value, you are telling the setcookie function to make the cookie available to all parts of example.com.If your wanting to set multiple different domains with the same cookie i.e www.example.com, www.example2.com, to my knowledge it can't be done with the setcookie as the cookie is only available to the domain that the setcookie function is executed on. Quote Link to comment Share on other sites More sharing options...
dagnasty Posted September 27, 2006 Author Share Posted September 27, 2006 Correct. Multiple domains, not subdomains.can anyone confirm this? what about through javascript? Quote Link to comment Share on other sites More sharing options...
acdx Posted September 27, 2006 Share Posted September 27, 2006 [code]<?phpsetcookie("cookie", $value, time()+31556926, "/", ".website.com", 1);?>[/code]By setting "secure", the last parameter in your call, 1, a secure HTTPS connection is required for the cookie to be set.[quote="php.net"]Secure: Indicates that the cookie should only be transmitted over a secure HTTPS connection. When set to TRUE, the cookie will only be set if a secure connection exists. The default is FALSE.[/quote]so simply make it[code]<?phpsetcookie("cookie", $value, time()+31556926, "/", ".website.com");?>[/code] Quote Link to comment Share on other sites More sharing options...
dagnasty Posted September 27, 2006 Author Share Posted September 27, 2006 Ahhh that's it. I was reading the wrong part of the setcookie page and thought the boolean was for something else. Do you have any idea how I'd go about setting a cookie for a domain other than the one currently visited? It's not letting me do it right now. Quote Link to comment Share on other sites More sharing options...
dagnasty Posted September 28, 2006 Author Share Posted September 28, 2006 Does anyone have any idea how I could set cookies for multiple domains through 1 page? I'm all out of ideas. I've tried using frames and iframes and it works in firefox but not in IE. Quote Link to comment 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.