Problems related to converting the value of 0 in a session to false

Source: Internet
Author: User
If the value of the session is 0, the problem A page * determines whether the SESSION is enabled * & nbsp; & nbsp; if (session_id () & nbsp ;? & Nbsp; false & nbsp;: & nbsp; true) & nbsp; & if the value of 0 in the session is set to false

/* Determine whether the SESSION is enabled */
If (session_id ()? False: true)
Session_start ();
$ _ SESSION ['uid'] = 0;
$ _ SESSION ['username'] = 'admin ';

Page B

/* Determine whether the SESSION is enabled */
If (session_id ()? False: true)
Session_start ();
Print_r ($ _ SESSION );
Var_dump ($ _ SESSION ['uid']);

Execute page A and then execute page B.

Array ( [uid] => [username] => admin ) bool(false)

The Cookie scope is normal, and the local test does not have cross-domain problems. The session_id and page encoding of the two pages are consistent. On page A, $ _ SESSION ['uid'] is int (0), while on page B is bool (false). This problem is confusing for two days, please kindly advise

------ Solution --------------------
I run your code normally.
------ Solution --------------------
Some frameworks will run session_start on their own. Are there any problems?
------ Solution --------------------
Apparently, your framework judges and processes $ _ SESSION ['uid '].
Since it is a "niche", you can find it slowly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.