Forum Moderators: coopster

Message Too Old, No Replies

Ajax request and session_start() stops the Refresh

Can't refresh the page when session_start() is set.

         

BlackDex

1:18 pm on May 17, 2006 (gmt 0)

10+ Year Member



I Have an very strange problem.

When i execute an very simple Ajax request to an PHP script wich just print one line and i put an sleep(20) infront of it, it works perfectly when i refresh the page.

BUT..
When i put session_start() at the top, i can't refresh the page anymore.
It won't refresh untill the server responed.

When i remove the session_start(), i can refresh anytime i want.

Is this a know problem?
Does someone knows an solution?

Thx for the help.

BlackDex

5:30 pm on May 17, 2006 (gmt 0)

10+ Year Member



It seems that session_start() puts an LOCK on the session file.

This results in a delay when several requests are started.

The solution seems simple.
Put an session_write_close() asap.

So create an function which reads/writes session data, and have it session_start() and session_write_close() every time.

jatar_k

5:32 pm on May 17, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



nice

I looked around but didn't think of that

so it worked then?

BlackDex

6:07 am on May 18, 2006 (gmt 0)

10+ Year Member



With my small test it worked :).

Havent put it to greate scale yet.
Gona do that today :).

Ill let ya know if this work irl big projects.

BlackDex

11:25 am on May 18, 2006 (gmt 0)

10+ Year Member



Hello again,

Well it is implemented now.
And i have to say.. It works absolutly perfect.
This is a greate way.

Just create 2 functions which read/write the session var, and put session_start() and session_write_close() around it...

Hope this will help other ppl :).