user1683645
user1683645

Reputation: 1579

redirecting after logout

I'm having problem redirecting the user to the frontpage when he logs out. I have a switch case statement and the one handling logout looks like this:

    case 'logout':
    offline($_SESSION['user_id']);
    session_destroy();
    include_once 'index.php';
    break;

I thought that including index.php would redirect the user to the frontpage since that's what should happen when the session. but the page is just blank and the url is localhost/web//?a=logout.

What am I doing wrong?

Upvotes: 0

Views: 734

Answers (1)

samayo
samayo

Reputation: 16495

Ok, OP! I have updated my answer, even though you didn't ask for it. So, check it this again

put header('Location: http://site.com/index.php');

Make your code like this:

case 'logout':
    offline($_SESSION['user_id']);
    session_destroy();
  header('Location: http://site.com/index.php');
   exit();
    break;

Upvotes: 2

Related Questions