PHP SESSIONS are empty after reload page

我怕爱的太早我们不能终老 提交于 2019-12-24 03:44:12

问题


I have code

<?php
require_once("lib/functions.php");
$page = new page;



if(isset($_POST['jmeno'])){
    $page->mailit($_POST, $_SESSION['result']);
}

$_SESSION['f'] = rand(1,9);
$_SESSION['s'] = rand(1,9);
$_SESSION['result'] = $_SESSION['f'] + $_SESSION['s'];

?>

Before POST form it prints the right values, but after POST form the sessions are empty. I don't know why, looks like something is bad configured. So it's always show Bad counted result

Here is session configuration....


回答1:


make sure that this line of code:

session_start();

Is at the beggining of your php file, right after the opening php tag <?php

This line of code is used to start new or resume existing session, please see php manual here



来源:https://stackoverflow.com/questions/32180832/php-sessions-are-empty-after-reload-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!