PHP checks whether a user's session has any problems and does not work before <html>

Source: Internet
Author: User
PHP determines whether a user session has a problem. it does not work before & lt; html & gt;] & lt ;? Phprequire_once & nbsp; ('config. php'); // determine the user permission if ($ _ SESSION ['member'] & nbsp ;! = & Nbsp; "adm PHP determines whether a user's session is faulty and does not work before
]

 Require_once ('config. php ');

// Determine user permissions
If ($ _ SESSION ['Member ']! = "Admin "){
Echo "script" alert ('Please log onto it '); location = 'index. php'; script ";
}
?>


It didn't work before, and Firefox made a judgment, but ie still didn't work for PHP? Session? Firefox PHP session sharing: it didn't work before]
------解决方案--------------------
在页面顶部加一句session_start();
------解决方案--------------------
session和cookie是亲兄弟。

session_start()是对session信息进行初始化(在一定的概率下删除存在服务器的session文件,这个概率在php.ini中可以设置).

有不用session_start()也能访问session信息。。是因为你的cookie还在。然后服务器上的session文件也还在。这样就能读取到了。

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: info-contact@alibabacloud.com 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.