Usage among multi pages
tyler-x opened this issue · 1 comments
Thank you first for the nice and clean code!
But I have a question here. When trying to access session data among multiple pages application, do I need to include the new Session() statement every time?
Let's say on the login page, I have the DB & Session file included and $session=new Session(); executed. Then on the admin page I want to echo the stored $_SESSION['username'], I believe I also need to include the two files but do I need to run the new Session() again then echo the $_SESSION['username']?
Actually I tried both, both get me empty returned. The only difference is if I run the new session again, the session value in the database will be cleared and otherwise, it will just remain untouched. So I'm a little confused here.
Thanks again for your help~!
@tyler-x Yes, you would need to include the two files and run the new Session() on every page to access your session data. For example:
include("database.class.php"); //Include MySQL database class
include("mysql.sessions.php"); //Include PHP MySQL sessions
$session = new Session(); //Start a new PHP MySQL session