实现在同一方法中获取当前方法中新赋值的session值解决方法_php技巧

WBOY
Release: 2016-05-17 08:40:35
Original
898 people have browsed it

项目开发中遇到这样一个问题,在同一方法中对session数组进行赋值,但是想在此方法中接着使用此session,因为我是用的if…elseif…,由于排斥作用,在if条件中给session赋值后,再调用方法进入另一个elseif条件中就获取不到上一步的赋值,现将解决方法总结如下:

PHP SESSION有一个函数:session_write_close(),这个函数的作用是:写入session数据保存并且结束session。

手册中对该函数的描述中说到:Session data is usually stored after your script terminated without the need to call session_write_close()。

即:session数据通常是在脚本结束才保存数据,除非你调用了session_write_close()

至此问题得以解决。

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template