简体   繁体   English

会话无法在 chrome 中工作并在 Firefox 中工作

[英]session not working in chrome and working in firefox

My session is not working in chrome and safari browser and working in firefox.我的会话不能在 chrome 和 safari 浏览器中运行,也不能在 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如果我print_r($sessionuser)它不能在 chrome 或 safari 浏览器中工作,但在 Firefox 中工作

$sessionuser = $_SESSION['user'];

没有周围的引号+分号

I'd say that, other than your code has parsing errors, that you would have to use session_start();我想说,除了你的代码有解析错误之外,你必须使用session_start(); before you use $_SESSION[]在您使用$_SESSION[]之前

It might be that you have forgotten an old session cookie in firefox.可能是您忘记了 Firefox 中的旧会话 cookie。 I think it is possible to check this with firebug.我认为可以用萤火虫检查这一点。

Also check da5id's answer, it will fix the parsing error.还要检查 da5id 的答案,它会修复解析错误。

Try this尝试这个

session_start();

$sessionuser=$_SESSION['user'];

echo $sessionuser;

try the following.尝试以下。 It works on my chrome in LINUX.它适用于我在 LINUX 中的 chrome。

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

You have to check your browser cookie.您必须检查您的浏览器 cookie。 Your session not a set If cookie is disabled.您的会话不是一组如果 cookie 被禁用。 You have to go in browser setting and check cookie setting.您必须进入浏览器设置并检查 cookie 设置。

Just try试试看嘛

In my case I just reset chrome browser就我而言,我只是重置 chrome 浏览器

Go to chrome://settings/ then click advanced then reset转到 chrome://settings/ 然后单击高级然后重置

Just clear the cookies in your Google Chrome in the Setting.只需在设置中清除 Google Chrome 中的 cookie。

Privacy and Security -> Cookies and other site data -> See all cookies and site data隐私和安全 -> Cookie 和其他站点数据 -> 查看所有 cookie 和站点数据

Search by the domain name or IP and delete the existing cookies.按域名或 IP 搜索并删除现有的 cookie。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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