session_start seems to be very slow (but only sometimes)

前端 未结 6 1508
暗喜
暗喜 2020-12-05 10:23

For some odd reason, just today our server decided to be very slow during the starting of sessions. For every session_start, the server either times out after 30 seconds, or

6条回答
  •  无人及你
    2020-12-05 10:26

    Have you tried session_write_close(); ? This will disable write-ability in session variables but you can still read data from them. And later when you need to write a session variable, reopen it.

    I have also suffered from this problem but this thing worked like a charm. This is what i do:

    session_start(); //starts the session
    $_SESSION['user']="Me";
    session_write_close();   // close write capability
    echo $_SESSION['user']; // you can still access it
    

提交回复
热议问题