简体   繁体   中英

Set Cross Domain Cookies with Iframe- issue

I want to set cross domain cookies. Cookies has been set successfully, if login page is not redirect to other page. If page redirected after login then cookies is not set. what is the issues?

I am using following code to setcookies on

            echo "<iframe style='display:none;' id='myiframe' 
src='http://b.com/cookies.php?username=$username&password=$password&token=$token'>";
            echo "</iframe>";

if I use die(); function, then cookies is set on site b.com.

if i redirect this page to another page, cookies is not set.

/* Redirect to login page */

header("Location: $loginPage");
    exit();

why? Any idea?

Not sure if this helps you, but I created an NPM module for setting cookies across domains. If you wanted to use JS to set/get the cross-domain cookie, this may work better.

https://www.npmjs.com/package/cookie-toss

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM