Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

how to create session handling in php?

hai,

I want to restrict the users from directly accessing my other pages.ie they should go only thru my login page.
how to ensure this thru session handling in php.
can anyone solve me this issue.


thank you
manju
0
manju70
Asked:
manju70
1 Solution
 
lokeshvCommented:
just register a SESSION veriable like SESSION_ID on ur login page and make entry of that in database. and now keep check that SESSION id on every page....



Hope this will help

LK

0
 
andrivCommented:
It depends on what the content is. I think the easiest but efficient way of handling it is to create an error page with login form:

Access Denied, Please provide a valid username and password:



On all the pages you want to secure look for the session you set to validate access, if the session does not exist redirect them to the error page.

For example add this to the top of all the pages:

<?
session_start();

if(!isset($session_variable)) // if($session_variable != "whatever"
{
header("Location: path/to/error.php");
}
?>


If the session does was not set they will be immediately redirected to the error page.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now