php session variable not working in new subfolers

Go To


i was developing my php application and using mysql to store session data and $_SESSION was working fine in both root and subfolers. but now when i create new subfolers , writing sessions works in them but i can't read the sessions . for example

$_SESSION['username'] = 'james';

it works fine and both session_id and session_data are stored in my mysql session table. and the session id stored in my browser matches the id in table but when i want to use it(read data from mysql) it doesn't work in new subfolers . for example:

echo $_SESSION['username'];

it doesn't work. and it's funny because when i copy the file in my previous subfolers it works all fine. and i don't use .htaccess in my subfolers.

really confused. thanks for help

2012-04-03 21:54
by Aliweb


You're probably missing session_start(); on one or more pages.

Edit: Like Zanrok said, it's hard to diagnose your problem without seeing any of your code.

2012-04-03 21:56
by Norse
Without seeing more of the code, I would have to take the same guess. Or possibly an included file linked wrong because of the directory switch - Zanrok 2012-04-03 21:58
read my question completely . i said 1) writing session data works . it means i didn't miss session_start() . 2) when i copy the file in previous subfolders it works fine while both subfolers are completely similar except for their names - Aliweb 2012-04-03 22:00
Why is this answer marked as correct when it suggests you do something you claim you've already done - bikey77 2012-09-27 06:37