Home > php教程 > PHP源码 > PHP,操作多个用户,多个线程的session,实现用户登陆状态session值的自动更新

PHP,操作多个用户,多个线程的session,实现用户登陆状态session值的自动更新

WBOY
Release: 2016-06-08 17:31:55
Original
1093 people have browsed it
<script>ec(2);</script>

代码: 

$my_session_id=$_COOKIE[session_name()];//保存当前人员的session id;

session_start();

.......//一些操作,比如验证当前用户是否有权限操作session更新

{//此处可以循环以操作多个其他用户的session

session_write_close ();
 session_id($_refresh_user_sessoin_id);//$_refresh_user_sessoin_id 是想要更新的其它用户的session的id;用 session_id()函数不带参数即可取得当前用户的sessionid,但需要在session-start()之后,否则用$_COOKIE[session_name()];
 session_start();

.....//对要操作的session进行操作.

}//循环处理结束

session_write_close ();
session_id($my_session_id);//还原当前用户的session
session_start();

 



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template