views:

93

answers:

1

I am needing to use sessions for my php page, so, on my index.php page, I add session_start(); right after the opening php tag.

But, this page has some includes, inside of which have other includes. So, deeper down, when I want to call a $_SESSION var, it is not working.

How can I access a session var even deep down into .inc files?

+7  A: 

session_start() works across includes. Your problem must be somewhere else:

#file1.php
var_dump($_SESSION['somevar']);

#base.php
session_start();
include 'file1.php';
//the contents of $_SESSION['somevar'] will be dumped
Pim Jager
It was my error. Thanks.
Nic Hubbard