Transfer cookies to subdomains located on different servers, implemented using PHP
P粉046878197
P粉046878197 2023-07-31 13:04:34
0
1
467
<p>How to pass cookies when the subdomain is on a different server? <br /><br />Basically, the main domain is at siteground and the subdomain is at softr.io. <br /><br />I am using this for authentication, so when someone logs into the main domain, he/she can also access the login session on the subdomain. <br /><br />softr.io cannot add PHP code, so I can only use JavaScript on the subdomain. <br /><br />I used the following cookie code:</p><p><br /></p> <p><code>setcookie($cookie_name, $cookie_value, $expiration_time, '/', $subdomain, true, true);</code></p> <p>It shows the cookie in the application tab of the developer tools, but is not accessible in JavaScript via document.cookie. <br /><br />Is there anyone here who has tried this type of task and can guide me. <br /><br />I researched for hours but couldn't figure it out. </p><p><br /></p>
P粉046878197
P粉046878197

reply all(1)
P粉130097898

The seventh parameter of setcookie is the HTTP Only flag.

You set it to true, which explicitly prevents it from appearing in document.cookie.

If you want to read it using client JS, please turn off this security feature.


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!