koca79331
koca79331

Reputation: 421

PHP SESSIONS are empty after reload page

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.... enter image description here

Upvotes: 2

Views: 2404

Answers (2)

Portekoi
Portekoi

Reputation: 1147

Make sure that your file had UTF-8 encoding. (not UTF-8-BOM)

Upvotes: 0

Luthando Ntsekwa
Luthando Ntsekwa

Reputation: 4218

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

Upvotes: 4

Related Questions