MoMoMajor Posted August 3, 2009 Share Posted August 3, 2009 Ok so I have been working on a site for a few days and I got the site working on localhost on my comp perfectly. Sessions, database and all that. I get hosting online and now my sessions don't work. The user will log in and it will welcome them and direct them to their page but after they click they are automatically logged out because none of the session variables work. Is there something you have to change when you go with actual hosting or something? Link to comment https://forums.phpfreaks.com/topic/168613-session-problem/ Share on other sites More sharing options...
gevans Posted August 3, 2009 Share Posted August 3, 2009 Can you show the login script, and how you are setting your sessions? Link to comment https://forums.phpfreaks.com/topic/168613-session-problem/#findComment-889422 Share on other sites More sharing options...
MoMoMajor Posted August 3, 2009 Author Share Posted August 3, 2009 if (isset($_POST['submitlogin'])) { //check username if (($_POST['page_user'] == $usersnme) && (md5($_POST['page_pass']) == $userspass)) { $_SESSION['user_name'] = $user_name; $_SESSION['user']= 'admin'; echo "Thank you for logging in<strong> ".$_SESSION['user_name']."[".$_SESSION['user']."]</strong>"; echo "Please click <a alt='home' title='Go' class='' href='../{$page_url}'>here<br/><br/></a>"; die(); } else if ((md5($_POST['p_pass']) == $p_pass) && ($_POST['p_user'] != $usersnme)) { $_SESSION['user'] = 'participant'; $_SESSION['user_name'] = $_POST['page_user']; $_SESSON['users_pass'] = $page_password; echo "Thank you for logging in ".$_SESSION['user_name']; echo "<br><br><strong>Please click <a href='../".$page_url."/'>here</a></strong> <br><br>"; die(); } } The problem is that once the user clicks the button the sessions disappear and it is really frustrating seeing as I had it working perfect on my machine :facewall: I started the session at the start of the page. Link to comment https://forums.phpfreaks.com/topic/168613-session-problem/#findComment-889440 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 make sure you have session_start() on top of every page and that sessions are allowed on your new hosting... Link to comment https://forums.phpfreaks.com/topic/168613-session-problem/#findComment-889445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.