开发者

Why my session key is invalid in php?

First I use this url to get the JSON result.....on the browser:

http://localhost:8888/myApplication/service/user_data.php?action=loadData&email=iiii%40cccc.com&sessionKey=aSessionKey

It works, and great, but I would like to get the JSON on this page, so I use this method the get the JSON....

$dataInJSON = file_get_contents('http://localhost:8888/myApplication/service/user_data.php?action=loadData&email=theEmail%40aEmail.com&sessionKey=aSessionKey'); 

echo $dataInJSON; 

but when I echo the dataInJSON, it should me th开发者_Python百科at the error code, that indicated the session key is invalid. So, I try to print the SESSION..... When I print the link in the browser using this method.....

    error_log(isset($_SESSION[$aEmail]));

it show me "1", which tell me the $_SESSION[$aEmail] is set, but when I use the second method, I found that it paste nothing..... when they have so different behavior? Thank you.


Try (in order to see what is the true value of variables) :

echo '<pre>';
var_dump($dataInJSON);
echo '</pre>';

echo '<pre>';
var_dump($_SESSION);
echo '</pre>';

echo '<pre>';
var_dump($_SESSION[$aEmail);
echo '</pre>';


Is user_data.php trying to compare or read values from $_SESSION? I don't think file_get_contents() will carry any sort of cookies or session data or anything.

If you need to send cookies and/or session data, try using cURL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜