tags:

views:

65

answers:

3

HI ,

When I try to logout using the following code in IE it for some reasons just loops and loops and loops and wont stop.

<?php $_SESSION = array(); session_destroy(); ?> 

<meta http-equiv="refresh" content="0;index.php">

Still getting some error's with this.

It seems that in IE it keep refreshing every second if I change 0 to 20 its every 20 seconds but the thing is it does not get to index.php it says on the current screen which is logout.php

+5  A: 

Noticed you don't seem to call session_start() in your page anywhere. You can't destroy a session without starting it first.

Mike B
+1: As counter-intuitive as the function name is, this is most likely the problem. (It should probably be named `session_init()`)
R. Bemrose
I don't find much difference between `_start` and `_init`... Nor do I find `session_start` to be an unintuitive name.
Adriano Varoli Piazza
A: 

Change your content="0 to 20. Try viewing the source to be sure that you're page is not showing this meta tag. If it is, fix the bug. If it's not, then it's something else.

Webnet
+4  A: 

Instead of using a meta refresh, why not direct them back to index.php with a header?

<?php
  $_SESSION = array();
  session_destroy();
  header('Location: index.php');
?>
Psilokan
I always add an `exit` after a `header()` call, even if it's the end of the code, in case someone later extends it and finds trouble.
Adriano Varoli Piazza
Agreed, thanks for pointing that out. Some bots (ie: Googlebot) do not follow headers. I've heard of Googlebot deleting records and things like that because people left them out.
Psilokan