PHP 会话不保存 [英] PHP Session not Saving

查看:34
本文介绍了PHP 会话不保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我网站的每一页的第一行都写了这个.

I have this written at the very first line on every page of my website.

include("restd.php");

和restd.php包含以下几行:

and restd.php contains the following lines :

@session_start();
if(isset($_SESSION['id']))
{
}
else
{
  header("location:index.php");
}

我面临的问题是,当我在我的网站上单击或执行某些操作时.它让我退出并带我到 index.php.

The problem i'm facing is that when ever i click or do something on my website. it logs me out and takes me to index.php.

我确定这与会话有关.我尝试了每件事来避免这个问题,但我使用了restd.php,因为我不希望任何人复制某人的网址并粘贴并进入网站.

im sure its something to do with the session. ive tried every single thing to avoid this problem but i ahve used restd.php because i dont want anyone to copy the url of someone and paste and get into the website.

只有登录的人才能查看其他人的页面.如果他们没有登录,那么他们将被重定向到 index.php

anyone who is logged in only can view other's pages. if they arent logged in then they'll be redirected to index.php

伙计们一个令人困惑的事情是,这一切在我的测试服务器上运行良好,这是 easyPHP-5.3.8.0,但是当我将所有文件上传到我的服务器时,这个问题就出现了.

EDIT : and guys a confusing thing is that all this is working fine on my testing server which is easyPHP-5.3.8.0 but this problem is coming up when i upload all the files to my server.

推荐答案

您的会话目录(可能是 /tmp/)不可写.

Your session directory (probably /tmp/) is not writable.

检查 session_save_path() 如果它是可写的.

Check with session_save_path() if it is writable.

if (!is_writable(session_save_path())) {
    echo 'Session path "'.session_save_path().'" is not writable for PHP!'; 
}

这篇关于PHP 会话不保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆