Solved

how to create session handling in php?

Posted on 2002-04-02
2
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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