Full-Demon Posted September 18, 2008 Share Posted September 18, 2008 Hi, I try to make a bridge between an SMF forum and my own site, where the user registers and logs in at my site and is automatically registered and logged in on the forum (via the site). SMF requires me to set a cookie to indicate the user is online, I made it to work on my localmachine, where I set the cookies path to be '/' (which is, the whole domain). But on my server it doesn't work, I think it's because they host multiple sites per server, and disabled this feature. How can I make a cookie to work on a different path on the site then it is created in? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/124830-cookies-for-a-different-direcory/ Share on other sites More sharing options...
JonnoTheDev Posted September 18, 2008 Share Posted September 18, 2008 You can only set a cookie to a directory that you have permissions to. You cannot save a cookie to another webserver by default. To save a cookie to a certain path use the setcookie() function i.e: setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1); Quote Link to comment https://forums.phpfreaks.com/topic/124830-cookies-for-a-different-direcory/#findComment-644862 Share on other sites More sharing options...
Full-Demon Posted September 18, 2008 Author Share Posted September 18, 2008 You can only set a cookie to a directory that you have permissions to. You cannot save a cookie to another webserver by default. To save a cookie to a certain path use the setcookie() function i.e: setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1); Yep, I know but it didn't work (that's just a copy from php.net ). They're on the same webserver, just different subdomains (where the subdomain is actually a directory in the www folder...). Quote Link to comment https://forums.phpfreaks.com/topic/124830-cookies-for-a-different-direcory/#findComment-645111 Share on other sites More sharing options...
Full-Demon Posted September 19, 2008 Author Share Posted September 19, 2008 *bump* Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/124830-cookies-for-a-different-direcory/#findComment-645752 Share on other sites More sharing options...
discomatt Posted September 19, 2008 Share Posted September 19, 2008 I believe a subdomain is still considered a different domain, for security purposes. You can't set a cookie for sub1.site.com from sub2.site.com... this would be very hectic for subdomain-based hosting. The only thing you can do is set a cookie in the parent domain... '.site.com' which will be accessible by both subdomains. Quote Link to comment https://forums.phpfreaks.com/topic/124830-cookies-for-a-different-direcory/#findComment-645814 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.