Current location: Hot Scripts Forums » Programming Languages » PHP » php session problem.(HELP PLEASE)

php session problem.(HELP PLEASE)

Reply
  #1 (permalink)  
Old 03-22-04, 11:23 AM
justme justme is offline
New Member
 
Join Date: Mar 2004
Location: United Kingdom
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
php session problem.(HELP PLEASE)

I have a sessions problem with my site and am hoping someone can help.
I have a membership system which iI now have functional and works a treat.
In my script thats checks and validates the user I register session variables and caryy them throughout the site for the visit length.
This code is
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
session_register('special_user');
$_SESSION['user_level'] = $user_level;
session_register('username');
$_SESSION['username'] = $username;
session_register('password');
$_SESSION['password'] = $password;

mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");

header("Location: login_success.php");

With an else statement here to trigger an alternative event.
########################################
When i echo sessions on test page all is well with this code, so I know the sessions are correct.

echo $_SESSION['first_name'];
echo $_SESSION['last_name'];
echo $_SESSION['email_address'];
echo $_SESSION['user_level'];
echo $_SESSION['username'];
echo $_SESSION['password'];

When trying to prevent access from specific pages with

session_start();
if (!isset($HTTP_SESSION_VARS['first_name']) || $HTTP_SESSION_VARS['first_name'] != "first_name") {
header ("Location: /members/login_form.html");
}

I am redirected to the login page. To my mind the code above should let me access the page as the session does exist. I am running on a Apache Server with globals on and php4, so could that cause a problem with HTTP_SESSION_VARS. If anyone can shed light I would be grateful.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-22-04, 11:56 AM
Keith's Avatar
Keith Keith is offline
Community VIP
 
Join Date: Feb 2004
Posts: 1,176
Thanks: 0
Thanked 3 Times in 3 Posts
Without seeing the entire script, would this change help?

Change:
PHP Code:
session_start();
if (!isset(
$HTTP_SESSION_VARS['first_name']) || $HTTP_SESSION_VARS['first_name'] != "first_name") {
header ("Location: /members/login_form.html");

To:
PHP Code:
session_start();
if (!isset(
$HTTP_SESSION_VARS['first_name']) || $HTTP_SESSION_VARS['first_name'] != $first_name) {
header ("Location: /members/login_form.html");

Just a shot in the dark.

Last edited by Keith; 03-22-04 at 11:58 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-22-04, 01:51 PM
justme justme is offline
New Member
 
Join Date: Mar 2004
Location: United Kingdom
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

Bang on Keith. Many thanks for the effort your a star. Cant beleive I was that close yet still still missing the point. Its obvious now you pointed it out. Thanks again .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-22-04, 02:47 PM
Keith's Avatar
Keith Keith is offline
Community VIP
 
Join Date: Feb 2004
Posts: 1,176
Thanks: 0
Thanked 3 Times in 3 Posts
No problem
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 01:22 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
Pass php session onto a popup? MTsoul PHP 2 11-30-03 12:16 PM
Realtime PHP Code Obfuscation barrywien General Advertisements 1 11-16-03 06:50 PM


All times are GMT -5. The time now is 12:42 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.