Hi,
I have run into a really strange problem. I have been designing a site using Sessions to manage logins.
Sessions were working beautifully all through development, but since last week it just stopped.
Here is the order in which a user of the site logins in:
1: index.php w\ an iframe for the login: user types in username and password
2: form submits to login1.php - which validates the username and password.
3: If successful, form variables are sent to logincomplete.php - which adds variables to $_SESSION.(code below)
<?php
ob_start("ob_gzhandler");
session_start();
$memberID = $HTTP_GET_VARS['id'];
$username = $HTTP_GET_VARS['user'];
$password = $HTTP_GET_VARS['pass'];
$type = $HTTP_GET_VARS['type'];
$email = $HTTP_GET_VARS['email'];
$fName = $HTTP_GET_VARS['fname'];
$lName = $HTTP_GET_VARS['lname'];
$remember = $HTTP_GET_VARS['rememberme'];
$_SESSION["member_id"] = $memberID;
$_SESSION["member_username"] = $username;
$_SESSION["member_password"] = $password;
$_SESSION["member_type"] = $type;
$_SESSION["member_email"] = $email;
$_SESSION["member_firstname"] = $fName;
$_SESSION["member_lastname"] = $lName;
$_SESSION["logged_in"] = "yes";
if($remember == "yes")
{
setcookie("exact[member_username]","$username",time()+60*60*24*30);
}
?>
<script language="javascript">
window.location="profile.php";
</script>
4: Then the profile page will bring up related information for the user. Profile.php starts like this:
<?php
ob_start("ob_gzhandler");
session_start();
include("includes/dbConn.php");
if(is_null($_SESSION['member_id']))
{
die("I shouldn't get here"); <--- the scripts gets to this line
if(!is_null($_SESSION['tmp_id']))
{
$conn = mainConnect();
$query = "Drop table ".$_SESSION['tmp_tablename'];
mysql_query($query,$conn) or die(mysql_error()." Line 21");
$_SESSION['tmp_id'] = '';
$_SESSION['tmp_tablename'] = '';
session_destroy();
}
}
?>
So as I have said before, this worked just fine during development, but now when it gets to profile.php the Session variables are lost.
I have checked to see if the session ids were the same from logincomplete.php to profile.php and they were.
I checked to make sure the $_SESSION array wasn't empty before sending the browser to profile.php and it wasn't.
Here is the current settings for Sessions from phpinfo():
Session Support enabled
Registered save handlers files user
session.auto_start Off
session.bug_compat_42 On
session.bug_compat_warn On
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure Off
session.entropy_file no value
session.entropy_length 0
session.gc_divisor 100
session.gc_maxlifetime 1440
session.gc_probability 1
session.name PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path c:\winnt\temp\php4
session.serialize_handler php
session.use_cookies On
session.use_only_cookies Off
session.use_trans_sid Off
This has been really puzzling to me because it should be simple and straight forward.
I am calling session_start() at the top of every page and new sessions are not being created from page to page.
Any ideas on what could be going on?
I have run into a really strange problem. I have been designing a site using Sessions to manage logins.
Sessions were working beautifully all through development, but since last week it just stopped.
Here is the order in which a user of the site logins in:
1: index.php w\ an iframe for the login: user types in username and password
2: form submits to login1.php - which validates the username and password.
3: If successful, form variables are sent to logincomplete.php - which adds variables to $_SESSION.(code below)
<?php
ob_start("ob_gzhandler");
session_start();
$memberID = $HTTP_GET_VARS['id'];
$username = $HTTP_GET_VARS['user'];
$password = $HTTP_GET_VARS['pass'];
$type = $HTTP_GET_VARS['type'];
$email = $HTTP_GET_VARS['email'];
$fName = $HTTP_GET_VARS['fname'];
$lName = $HTTP_GET_VARS['lname'];
$remember = $HTTP_GET_VARS['rememberme'];
$_SESSION["member_id"] = $memberID;
$_SESSION["member_username"] = $username;
$_SESSION["member_password"] = $password;
$_SESSION["member_type"] = $type;
$_SESSION["member_email"] = $email;
$_SESSION["member_firstname"] = $fName;
$_SESSION["member_lastname"] = $lName;
$_SESSION["logged_in"] = "yes";
if($remember == "yes")
{
setcookie("exact[member_username]","$username",time()+60*60*24*30);
}
?>
<script language="javascript">
window.location="profile.php";
</script>
4: Then the profile page will bring up related information for the user. Profile.php starts like this:
<?php
ob_start("ob_gzhandler");
session_start();
include("includes/dbConn.php");
if(is_null($_SESSION['member_id']))
{
die("I shouldn't get here"); <--- the scripts gets to this line
if(!is_null($_SESSION['tmp_id']))
{
$conn = mainConnect();
$query = "Drop table ".$_SESSION['tmp_tablename'];
mysql_query($query,$conn) or die(mysql_error()." Line 21");
$_SESSION['tmp_id'] = '';
$_SESSION['tmp_tablename'] = '';
session_destroy();
}
}
?>
So as I have said before, this worked just fine during development, but now when it gets to profile.php the Session variables are lost.
I have checked to see if the session ids were the same from logincomplete.php to profile.php and they were.
I checked to make sure the $_SESSION array wasn't empty before sending the browser to profile.php and it wasn't.
Here is the current settings for Sessions from phpinfo():
Session Support enabled
Registered save handlers files user
session.auto_start Off
session.bug_compat_42 On
session.bug_compat_warn On
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure Off
session.entropy_file no value
session.entropy_length 0
session.gc_divisor 100
session.gc_maxlifetime 1440
session.gc_probability 1
session.name PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path c:\winnt\temp\php4
session.serialize_handler php
session.use_cookies On
session.use_only_cookies Off
session.use_trans_sid Off
This has been really puzzling to me because it should be simple and straight forward.
I am calling session_start() at the top of every page and new sessions are not being created from page to page.
Any ideas on what could be going on?