Home >Backend Development >PHP Tutorial >Solution to obtain the session value newly assigned in the current method in the same method_PHP tutorial

Solution to obtain the session value newly assigned in the current method in the same method_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:26:16911browse

I encountered such a problem during project development. I assigned a value to the session array in the same method, but I wanted to use this session again in this method. Because I used if...elseif..., due to the repulsion effect, in the if condition After assigning a value to the session, and then calling the method to enter another elseif condition, the assignment in the previous step cannot be obtained. The solution is summarized as follows:

PHP SESSION has a function: session_write_close(). The function of this function is to write session data, save it and end the session.

The description of this function in the manual says: Session data is usually stored after your script terminated without the need to call session_write_close().

That is: session data is usually saved at the end of the script, unless you call session_write_close().

This problem is solved.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824785.htmlTechArticleI encountered such a problem during project development. The session array is assigned a value in the same method, but I want to use it in this method. Then use this session, because I am using if...elseif..., due to row...
Statement:
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