在 ajax 中在哪里使用 session_write_close()


Where to use session_write_close(), in ajax

我的问题是,当ajax请求正在进行时,用户可能会单击"联系我们"或其他链接,但会话被锁定,从ajax,用户必须等待,然后才能获得下一个链接。

main url:
    makes ajax call,
    displays data
ajax target:
    looks at $_SESSION for various reasons,
    calls an api (this will take 5 seconds), 
    makes changes to $_SESSION,
    returns some values

在这 5 秒内,用户点击"联系我们"

onclick: ajax is aborted, by jquery.
    I dont care, anymore, what the ajax target did.  
    Any changes to SESSION dont matter much, either way.
user has to wait the 5 seconds, then the contact page loads.

在哪里使用session_write_close()? 在这种情况下,甚至可能吗?(鉴于我必须写信给SESSION,在正常情况下)

session_start()
looks at $_SESSION for various reasons
  - make copy of values if necessary
session_write_close()
calls an api (this will take 5 seconds), 
session_start()
  - some kind of optimistic lock checks if necessary
makes changes to $_SESSION,
returns some values