Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/124830-cookies-for-a-different-direcory/
Share on other sites

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);

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 :P).

 

They're on the same webserver, just different subdomains (where the subdomain is actually a directory in the www folder...).

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.

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.