Jump to content

Sessions Help


almystersv

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.