I am currently working on developing a simple web system, so an user first will be directed to a login page, then a processing page. If its account data provided is correct, it will be directed to the main page, so it can carry out some actions, at last it can logout.
So what I want to ask is: how can I prevent user to access the processing, main or logout page before they login, I mean, if I do not limit it, the login action is by some means useless. I am using wamp to develop the web system.
I have considered making use of the session variable, however, I have no idea how to check the value of the variable. If I start a session at the login page, so if I skip the login page but directed go to the main page, do I have those session variable present in the main page?
1) Add
session_start();at the top of the php page to initialize sessions.2) Add if statement
3) Create a login form which validates data, if data is correct then it adds
$_SESSION['logged_in'] = 1;and redirects to profile page with logout button.That’s all :)!
I suggest that you check some tutorials, since it will give you some more information how to do that – http://www.intechgrity.com/create-login-admin-logout-page-in-php-w/ or any other link via google – “How to create login/logout functions with SESSIONS”.
About your question, in each page you will put
session_start();at the start of the file, they will have all sessions you have specified for user.EDIT:
Added few useful links –
http://www.php.net/manual/en/book.session.php
http://www.tizag.com/phpT/phpsessions.php/
http://www.w3schools.com/php/php_sessions.asp