使用session_write_close()时的PHP Save Session; [英] PHP Save Session when using session_write_close();

查看:150
本文介绍了使用session_write_close()时的PHP Save Session;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一页要进行长时间的民意调查,我必须在此页的开头使用此

I've one page where i do a long polling i've to use at the begin of this page this

session_start();
session_write_close();

因为:

为防止并发写入,任何时候任何会话都只能操作一个脚本

to prevent concurrent writes only one script may operate on a session at any time

因此,如果我不这样做并且长时间轮询正在运行,则用户将无法加载其他页面.

So if i do not and the long polling is running the user will not be able to load another page.

因此可以从此轮询页面访问会话中的数据,但是在脚本的某个时刻,我必须将会话保存回服务器,因为我做了一些更改.

So accessing to my data in session from this polling page is possible but at some point in my script i've to save my session back to the server because i made some change in it.

这是怎么做的?

那太好了,这将是做类似事情的一种方式

That will be very nice it'll be a way to do something like

session_write_open();
//do stuff
session_write_close();

但是session_write_open()不存在!

But the session_write_open() doesn't exist!

谢谢

推荐答案

之前,对会话进行一些更改,然后再次调用session_start.进行更改,如果仍然不想退出,请再次调用session_write_close.您可以根据需要多次执行此操作.

Before you make some change to the session, call session_start again. Make the changes, and if you still do not want to exit call session_write_close once more. You can do this as many times as you like.

这篇关于使用session_write_close()时的PHP Save Session;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆