xcandiottix Posted July 13, 2010 Share Posted July 13, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/207613-strange-problem-with-registering-session-variable/ Share on other sites More sharing options...
Pikachu2000 Posted July 13, 2010 Share Posted July 13, 2010 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>'; Quote Link to comment https://forums.phpfreaks.com/topic/207613-strange-problem-with-registering-session-variable/#findComment-1085381 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2010 Share Posted July 13, 2010 Actually, session_register was depreciated in php4.2 when register_globals were turned off by default. Code to cause it to produce a depreciated error was only added in php5.3. Quote Link to comment https://forums.phpfreaks.com/topic/207613-strange-problem-with-registering-session-variable/#findComment-1085384 Share on other sites More sharing options...
Pikachu2000 Posted July 13, 2010 Share Posted July 13, 2010 Just repeating what the PHP manual says, that's all . . . This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. Quote Link to comment https://forums.phpfreaks.com/topic/207613-strange-problem-with-registering-session-variable/#findComment-1085388 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2010 Share Posted July 13, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207613-strange-problem-with-registering-session-variable/#findComment-1085395 Share on other sites More sharing options...
Pikachu2000 Posted July 13, 2010 Share Posted July 13, 2010 I guess I should have expected that to be the case. I knew it hasn't been supported for the last (bunch of) releases. Quote Link to comment https://forums.phpfreaks.com/topic/207613-strange-problem-with-registering-session-variable/#findComment-1085411 Share on other sites More sharing options...
xcandiottix Posted July 13, 2010 Author Share Posted July 13, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207613-strange-problem-with-registering-session-variable/#findComment-1085457 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.