Persistent DB session across subfolders
Ok I have a login page inside a directory with a sub folder. Now the session handler consists of database connection. When I go to one sub folder and from there inside a php file I call the session file from one level above as inlcude '../sessions.php' ; but it looks like I could use all variables from the sessions file but the database doesn't connect here and as a result the sql command doesn't execute inside the current file.
For reference this is the document folders tree.
/config.php ---> Database connection
/index.php ---> include 'session.php'
/login.php ---> include '../includes/config.php'
/session.php ---> include '../includes/config.php'
/index.php ---> include '../session.php' /*Here I couldn't access the database until I include the config.php directly here*/
Sorry for the complex explanation!
This is interesting. My guess is that because there there is a second level nesting involved the session loses its data. Check if you are correctly using session_start() in each of your files.
Has your problem been addressed?
session_start() is all fine. But doesn't work. I could make it work by adding the config file into to subfolder. But it doesn't inherit from sessions file.
I could also make it work by creating a function and calling it.