开发者

Sessions in programmatically requested pages

After doing some research on this issue, I couldn't find any satisfying fix.

The problem is: I'm performing a GET request programmatically. The request itself works fine and the requested page does so as well. I need to check for a valid login before performing any other actions within the requested page, therefore I've sent the Session cookie to receive the Session's ID, which also works fine. But as soon as I invoke *session_start( )*, the request exceeds the execution time limit of 60 seconds. Accessing the requested page directly works fine, though.

This might be an important remark: The requesting page also uses Sessions for the same checkings.

The reason why I want the requested page to be "remote" / "standalone" / however you want to call it, is that I want to make it accessible via AJAX as well. I suppose simply including the file and check whether the file is directly called would work as wel开发者_如何学JAVAl, but I've done it now this way and am almost satisfied with it.

My question now is: Can anybody tell me why session_start rather crashes my script? And does somebody know a patch for this?


Sessions are blocking in PHP, meaning that if you run two requests on the same host that use the same session, one of them will be blocked (waiting) until the first one has finished.

In your situation, if your programmatic GET request uses the client's session ID, it could be that the two scripts are blocking each other - and because the one is calling the other, the "child" script will wait indefinitely.

It's hard to suggest a solution without knowing your project, but it feels to me it isn't right to make a programmatic GET request with the client's session ID. Maybe you can change that behaviour.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜