php 会话在网络托管上发布后不起作用 [英] php session not working after publish on web hosting

查看:35
本文介绍了php 会话在网络托管上发布后不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站在 localhost 上运行良好,但是一旦我将其部署到我的托管服务,会话就会停止工作.

My website works fine on localhost, but once I deploy it to my hosting service, the session stops working.

<?php 

session_start();
session_save_path('log/session.txt');
ini_set('session.gc_probability', 1);
error_reporting(E_ALL ^ E_NOTICE);
date_default_timezone_set("Asia/Jakarta");
require_once 'jadwal/calendar/tc_calendar.php';

include "../metode/data.php"; 
include "../metode/jalan.php";
include "../metode/perintah.php";
include "../metode/gambar.php";

//session
$queryadmin = mysql_query("select * from root");
$dataadmin = mysql_fetch_row($queryadmin);
$id = $dataadmin[0];
$key1 = $dataadmin[1];

if (isset($_POST['admin'])) {
    $_SESSION['id'] = $_POST['x'];
    $_SESSION['key1'] = $_POST['xx'];
}
if (isset($_POST['root'])) {
    $_SESSION['user'] = $_POST['xxx'];
    $_SESSION['key2'] = $_POST['xxxx'];
}
if (isset($_POST['clear'])) {
    $_SESSION['id'] = "";
    $_SESSION['key1'] = "";
    $_SESSION['user'] = "";
    $_SESSION['key2'] = ""; 
}
if (isset($_POST['exit'])) {
    $_SESSION['id'] = "";
    $_SESSION['key1'] = "";
}

//access
if ($_SESSION['id'] == $id && $_SESSION['key1'] == $key1) {
    $user = $dataadmin[3];
    $key2 = $dataadmin[2];
    if ($_SESSION['user'] == $user && $_SESSION['key2'] == $key2) {
        mysql_query("insert into root history values('','".$_POST['day']."','".$_POST['time']."')");
    print "<br><br><br>";
    include_once "jembatan.php";
    } else {
        include "root.php";
    }
}
else {
    include "admin.php";
}

?>

如果你需要我展示任何其他文件,尽管问.

If you need me to show any other files, just ask.

推荐答案

可能是您的主机设置 PHP 的方式.尝试在主机上打印 phpinfo() 并检查它们的设置.

Could be the way your hosting set up their PHP. Try printing phpinfo() on the host and check their settings.

要运行 phpinfo 函数,只需运行如下所示的脚本:

To run the phpinfo function, just run a script that looks something like this:

<?php
    phpinfo();
?>

输出将包含大量设置,但您正在寻找这部分:

The output will include a huge list of settings, but you're looking for this section right her:

请注意我的设置如何显示会话支持 = 已启用.这表明我的主机(在我的情况下为 localhost)支持会话.

Note how my settings says Session Support = enabled. That's what indicates that my host (localhost, in my case) supports sessions.

这篇关于php 会话在网络托管上发布后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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