2

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

koca79331
  • 321
  • 4
  • 19

2 Answers2

4

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

Ahmad Baktash Hayeri
  • 5,802
  • 4
  • 30
  • 43
Luthando Ntsekwa
  • 4,192
  • 6
  • 23
  • 52
0

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

Portekoi
  • 1,087
  • 2
  • 22
  • 44