Reputation: 11382
I have information stored in a session. But was I just found out, sessions don't work when you do file_get_contents().
So after some searching I thought of using this technic:
$cart = base64_encode(serialize($_SESSION['cart']));
I pass my session cart, serialize it and encode it. I then pass it into the file_get_contents.
$url = "http://www.domain.com/pdf_order.php?cart=".$cart;
$html = file_get_contents($url);
In the URL that it gets, I have this:
$cart = unserialize(base64_decode($_GET['cart']));
But I don't get anything. I can print out the GET cart and I have an encoded string, but then I can't do anything with it.
Any help, much appreciated.
Upvotes: 2
Views: 11702
Reputation: 5169
Check out How to post data in PHP using file_get_contents? it's pretty much doing what you want to do, by creating a stream.
I'm guessing you can still put $_SESSION
variables in there too.
Upvotes: 1
Reputation: 94
If you are working on same server as www.domain.com then why do you need to use file_get_contents() to get some data or do some processing . Use direct calls.
Upvotes: 0