file get contents - How to make synchronous file_get_contents() GET request in PHP -
on site, needed way share session data between 2 domains (one using shared ssl certificate, , other 1 on plain http) redirect user secure domain normal 1 after logging in, while preserving session data.
so came with:
the user enters credentials in secure login page , submits form.
when form submitted, page refreshes. upon refresh, user authenticated, session started , session variables set. then, sid of user on secure domain gets sent data page on non-secure domain, secure sid set session variable.
the user gets redirected main non-secure page, session started, secure sid read, , finally, session on non-secure domain restarted secure sid. way, same session preserved across domains.
there 1 problem approach, file_get_contents() make gets canceled code reaches redirect header. in code:
//the following line never completes file_get_contents('http://nonsecuresite.com/cookie.php?sid=session_id()'); header('location: http://nonsecuresite.com');
of course sid encrypted, omitted sake of clarity.
is there way make script wait request complete before moving on next page, synchronous file_get_contents function?
Comments
Post a Comment