Solved

how to create session handling in php?

Posted on 2002-04-02
2
189 Views
Last Modified: 2010-05-18
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
Comment
Question by:manju70
2 Comments
 
LVL 4

Expert Comment

by:lokeshv
ID: 6914859
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
 
LVL 5

Accepted Solution

by:
andriv earned 30 total points
ID: 6915031
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question