简体   繁体   English

服务器上Cookie的PHP问题

[英]PHP issue with cookies on server

I am checking if the cookie exists or not. 我正在检查cookie是否存在。 Code run perfect on localhost but not working on server. 代码可以在localhost上完美运行,但不能在服务器上运行。

if(!isset($_COOKIE['checkuser']))
{
  // Create a cookie
}
else
{
  // do other other action
}

page is not being load on if accessing from webserver. 如果从Web服务器访问,则不会加载该页面。 but on localhost its work fine. 但是在本地主机上工作正常。 is there is some setting that I need to do for this ? 我需要为此做一些设置吗?

If your error is "the page is not loading" then it is almost certainly not related to the code you posted. 如果您的错误是“页面未加载”,则几乎可以肯定与您发布的代码无关。 You mention in a comment that you're doing some database calls in code you didn't post - that's far more likely to cause trouble than an isset() call. 您在注释中提到您正在使用未发布的代码进行一些数据库调用,这比isset()调用更容易引起麻烦。

What error are you seeing? 您看到什么错误? If you are seeing just a blank page, that's likely a syntax error which is being logged to the server's error log rather than to the screen, for security purposes. 如果仅看到空白页,则可能是语法错误,出于安全目的,该语法错误已记录到服务器的错误日志中而不是屏幕中。 Check your server's error logs for an associated message. 检查服务器的错误日志中是否有关联的消息。

It's likely your server is running either a different version of PHP or a different security level (PHP safe mode, for instance) which is causing it to fail on the server but not on your machine. 您的服务器运行的可能是其他版本的PHP或不同的安全级别(例如,PHP安全模式),这可能导致该服务器在服务器上但在您的计算机上失败。 Alternatively, it may be failing to connect to the server's database. 或者,它可能无法连接到服务器的数据库。

Please update your question with more information (more code and/or the exact error message would be a good start) if this isn't enough information to solve your problem. 如果此信息不足以解决问题,请使用更多信息(更多代码和/或确切的错误消息是一个好的开始)来更新您的问题。

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

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