简体   繁体   中英

session not working in chrome and working in firefox

My session is not working in chrome and safari browser and working in firefox. Can anyone explain why this is happening ?

 <?php
  session_start();

 $sessionuser=$_SESSION['user'];


 ?>

If I print_r($sessionuser) it is not working in chrome or safari browsers bu working in firefox

$sessionuser = $_SESSION['user'];

没有周围的引号+分号

I'd say that, other than your code has parsing errors, that you would have to use session_start(); before you use $_SESSION[]

It might be that you have forgotten an old session cookie in firefox. I think it is possible to check this with firebug.

Also check da5id's answer, it will fix the parsing error.

Try this

session_start();

$sessionuser=$_SESSION['user'];

echo $sessionuser;

try the following. It works on my chrome in LINUX.

session_start();
$_SESSION['user'] = "hithere";
$sessionuser=$_SESSION['user'];
print_r($sessionuser);

You have to check your browser cookie. Your session not a set If cookie is disabled. You have to go in browser setting and check cookie setting.

Just try

In my case I just reset chrome browser

Go to chrome://settings/ then click advanced then reset

Just clear the cookies in your Google Chrome in the Setting.

Privacy and Security -> Cookies and other site data -> See all cookies and site data

Search by the domain name or IP and delete the existing cookies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM