开发者

Php curl auto authentication not setting the session

I am using php curl function for auto authentication, and it works fine.But i开发者_StackOverflow am not able to go to another page on the same domain and I think session is not set.Help me please,thanks in advance.


In order to keep session information, you will need to tell CURL where to store Cookie data. You can do this with the CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR options set with curl_setopt.

EDIT Here's an example:

curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt")


With curl and rest-services you don't have session. So, as a solution your auth operation should return session_id and you should pass that session_id in the next request where request is signed. After that you should implement additional security checks by session_id.

The best way to me is to integrate OAuth2 authentication when you have access_token, expired_in and refresh_token. Refresh_token is optional parameter and you can use it when you try to get new access_token by refresh_token when access_token is expired.


You might need to send over the session cookie when going over to the other page to maintain state

See: Maintaining PHP session when using CURL

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜