PHP session_write_close()

PHP函式 php session_write_close()
End the current session and store session data.
session 的資料需要在 script 結束時才會儲存,所以當有2 個 script 同時執行時,後面的 script 會等前面的 script 執行完成再來跑,如果設定了  session_write_close() 就可以立即告訴程式,我後面的程序不會寫入 session 了,其他程式可以讀取 session 的內容來處理。

好處就是:程序不會被前一個 session 卡住,但是寫入 session 的行為就要很小心的處理。


說明: http://php.net/manual/en/function.session-write-close.php
Session data is usually stored after your script terminated without the need to call session_write_close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.