4

i have domain like www.example.com. In that i have 3 folders employee/account/dashboard in each folder i have separate login page. the problem is if i logged in 2 panels like www.example.com/employee, www.example.com/dashboard then if i logged out from any one panel automatically session destroyed another panel also. so how to solve the above problem. Note: i used different session variable in each subfolder.

session_start();
session_unset($_SESSION['admin_name']); //logout page for dashboard
header("location:index.php");

session_start();
session_unset($_SESSION['employee_id']); //logout page for employee
header("location:index.php");

i want if i logout from one panel(dashboard), the another panel (employee) should not logout.

CRABOLO
  • 8,605
  • 39
  • 41
  • 68
Vetrivel
  • 1,149
  • 1
  • 7
  • 16
  • This may help you.. : http://stackoverflow.com/questions/6730123/how-to-destroy-a-specific-php-session or http://php.net/manual/en/function.session-destroy.php – Chella Nov 17 '14 at 06:30

1 Answers1

2

Rather than using session destroy, I would consider consolidating each of your login profiles into one session, under separate variables. Each login and associated profile could be managed within a single object or array depending on the complexity required. That way, you could simply eliminate the single array for each section.

For Example after a successful login on the dashboard:

session_start();
$_SESSION['dashboard']=array();
$_SESSION['dashboard']['id']='whateverfromdatabase';
$_SESSION['dashboard']['loginname']='whatever-else';

and a logout would be:

session_start();
$_SESSION['dashboard']=array();
header("Location: index.php");
Dale
  • 319
  • 2
  • 8