Jump to content

Recommended Posts

I have a sign in page that forwards to a user page. I keep having a problem where when the user enters their username and password, they are forwarded to their user page but their status is not logged in. If I log in a second time everything is fine. I don't know if the page refresh is the issue or not?

 

Sign In

session_save_path("/tmp/");
session_set_cookie_params(0,'/','.site.com');
session_start();
session_register('active');
session_register('user');

if($row['db_Username'] == $usernameOK){
	if($row['db_Password'] === $passwordOK){
		//set session
		$uncookie = $row['db_Username'];
		$idcookie = $row['db_Id'];
		$_SESSION['active'] = $idcookie;
		$_SESSION['user'] = $uncookie;
		header("Location: http://www.site.com/member/user_page.php?u=".$uncookie."");
		exit;
		//end
	}

 

user_page.php

 

session_save_path("/tmp/");
session_set_cookie_params(0,'/','.site.com');
session_start();

if (isset($_SESSION['active'])){ //this code is NOT getting triggered although it should be since this was set on the previous page
}
else{
$restricted = 1;
}
if($restricted == 1){
if(!isset($_GET['u'])){
	echo '<meta http-equiv="refresh" content="1;url=http://www.site.com">';
}
else{
	$statusbar = 'You are not logged in <a href=http://www.site.com/public/signin.php>Click here to log in</a>';

 

I chopped the code to just show the parts that seem to be involved so ignore any small syntax errors (missing { etc).

Any suggestions?

Seeing what the $_SESSION array holds immediately after the redirect might provide some insight as to where the problem is. session_register is deprecated as of PHP 5.3.0, BTW.

 

in user_page.php

session_save_path("/tmp/");
session_set_cookie_params(0,'/','.site.com');
session_start();

echo '<pre>';
print_r($_SESSION);
echo '</pre>';

The only reason there are errors now for depreciated functions and features is because -

PHP 5.3.0 introduces two new error levels: E_DEPRECATED and E_USER_DEPRECATED

 

The statements in the documentation about any specific thing being depreciated in php5.3.0 is just some tech writer globally going through and adding that comment, regardless of when something was actually depreciated in favor of a different method.

I added the print session code and now I can't get it to repeat the problem. Very strange. I see it was mentioned that session_register is depreciated... does that mean I need to not use this? I believe before when I wrote this part of the code that the variables would not appear with out including this. Is it important to change this or can I still run it with out any problems? I don't get any error messages at any point.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.