almystersv Posted March 3, 2008 Share Posted March 3, 2008 Hello Everyone. I have a simple login working that allows people access to the system. With that I have sessions successfully working too. There are two areas to the system, the main area that people have to log into, and a second external area. This external area requires the users to login to it, and u can access it through the main system. Now my question is, Is it possible to keep the existing session open, including all its variables, even when they log into the external area so that when they leave the external area to go back into the main system they dont need to login and it has kept all their session variables!? if further info is needed just ask. Thanks Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/ Share on other sites More sharing options...
revraz Posted March 3, 2008 Share Posted March 3, 2008 Is the external area on the same domain? If not, the variables wont pass to the external site. But if they return to your site, their session should still be there if the inactivity timer hasn't hit. Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482404 Share on other sites More sharing options...
almystersv Posted March 3, 2008 Author Share Posted March 3, 2008 Hi, Yeah it is all in the same domain. I have tried it so that they just go back to the main page of the system when they leave the external area but it does not keep their old session variables as the headers/footers etc are determined by the users access levels. When they go back to the main system no headers or footers are called at all!? Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482414 Share on other sites More sharing options...
revraz Posted March 3, 2008 Share Posted March 3, 2008 Then it sounds like it's not the same domain name. Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482418 Share on other sites More sharing options...
almystersv Posted March 3, 2008 Author Share Posted March 3, 2008 Its all on local host at the moment? The user logs into the main system (Session starts) Then logs into external area (Session starts) Finishes in the external area and goes back to Main page of system. There muxt still be some sort of session running otherwise they would be refused access back into the main system completely. Will it work if I change the session names or anything like that?! Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482423 Share on other sites More sharing options...
revraz Posted March 3, 2008 Share Posted March 3, 2008 Would be easier if you posted the code to both pages. Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482425 Share on other sites More sharing options...
The Little Guy Posted March 3, 2008 Share Posted March 3, 2008 does the main system and the external system have require two separate logins? If your are doing to logins for one person (one for the main system and one for the external system) the sessions will overwrite each other unless you give them their own session variables. Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482434 Share on other sites More sharing options...
almystersv Posted March 3, 2008 Author Share Posted March 3, 2008 Login Check for main system <?php session_start(); require "connect.php"; $username = $_POST['username']; $password = $_POST['password']; $query = "select * from employee WHERE active ='y' AND username='".$username."' AND password='".$password."'"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $row=mysql_fetch_array($result); if($row!=null) { $_SESSION['username'] = $row['username']; $_SESSION['password'] = $row['password']; $_SESSION['type'] = $row['type']; $_SESSION['empID'] = $row['empID']; $_SESSION['fName'] = $row['fName']; $_SESSION['sName'] = $row['sName']; header('Location: welcome.php?var=msgDate'); exit(); } else if($username == "") { $message2 = "Please enter your Username"; header("Location: login.php?message2=$message2"); exit(); } else if($password == "") { $message3 = "Please enter your Password"; header("Location: login.php?message3=$message3"); exit(); } /*else if(active = "n") { $message4 = "Sorry, this users account has been de-activated. Please contact the system administrator." header("Location: login.php?message4=$message4"); exit(); }*/ else { $message = "Invalid user name or password, please try again"; header("Location: login.php?message=$message"); exit(); } ?> Login Check for external area <?php session_start(); require "connect.php"; $fileUsername = $_POST['fileUsername']; $filePassword = $_POST['filePassword']; $query = "select * from fileshare WHERE active ='y' AND fileUsername='".$fileUsername."' AND filePassword='".$filePassword."'"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $row=mysql_fetch_array($result); if($row!=null) { $_SESSION['fileUsername'] = $row['fileUsername']; $_SESSION['filePassword'] = $row['filePassword']; $_SESSION['type'] = $row['type']; $_SESSION['access'] = $row['access']; header('Location: fileshare.php'); exit(); } else if($fileUsername == "") { $message2 = "Please enter your Username"; header("Location: fileLogin.php?message2=$message2"); exit(); } else if($filePassword == "") { $message3 = "Please enter your Password"; header("Location: fileLogin.php?message3=$message3"); exit(); } /*else if(active = "n") { $message4 = "Sorry, this users account has been de-activated. Please contact the system administrator." header("Location: login.php?message4=$message4"); exit(); }*/ else { $message = "Invalid user name or password, please try again"; header("Location: fileLogin.php?message=$message"); exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482436 Share on other sites More sharing options...
almystersv Posted March 3, 2008 Author Share Posted March 3, 2008 I would prefer it if they had seperate logins. How do I go about implementing the variables so they do not overwrite?! Link to comment https://forums.phpfreaks.com/topic/94179-sessions-help/#findComment-482441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.