NickT
NickT

Reputation: 23873

$_SESSION variables not working

As a newcomer to PHP, I need to get $_SESSION variables working as part of a larger project. I am finding that the I cannot transfer data between .php files using $_SESSION variables. I Googled for similar problems and found this solved problem.Same problem

I reduced my code to the exact same as the solution to the problem, but it still exists. I have

sesstest.php

<?php
session_start();
$_SESSION['test']="TEST SESSION TEXT";
header('location:sessreceive.php');
?>

sessreceive.php

<?php session_start();
echo $_SESSION['test'];
?>

I have cookies enabled and it is the same in Firefox and IE. The site I'm accessing is a Raspberry Pi on my home network. It is running Apache2 under a Linux version. The session part of my php.ini is

Session section of php.ini

Could anyone please suggest what might be wrong, as I get no output in sessreceive.php?

Upvotes: 1

Views: 1737

Answers (2)

Andy
Andy

Reputation: 11985

  1. Can try var_dump($_SESSION);, to see what exactly it contains.

  2. Also, try echo session_id(); in both cases to ensure you're picking up the same session in both cases.

  3. Make sure Apache can write to the session.save_path (/var/lib/php5)

Upvotes: 0

Nahuelistico
Nahuelistico

Reputation: 42

Make sure that the session.save_path exists. Sometimes that is the problem.

Upvotes: 1

Related Questions