Hi

I am using the following code to logout:

my logout button calls logout.php

logout.php

<?
session_start();
session_destroy();
header("location:site.php");
?>

This doesnt seem to reidrect to my site.php page, it just loads a blank logout.php page, any ideas?

Recommended Answers

All 8 Replies

Make sure there isn't any output (even a newline or white space) before the <? bracket. Hope this helps :)

if it's a blank page, there's most likely errors, try putting a error_reporting(E_ALL ^E_NOTICE) on the top of the script

I have tried using error_reporting at the top of the script, and it doesnt show up any errors......

Is there any script on site.php that checks if a user is logged in or logging out that could redirect back to the logout page?

no there isnt.

Post the codes in site.php.

sorted it, i had missed 'php'

<?php

there is a mistake that you can also make when using header() function which is spacing between the full column (:) before the page you are redirecting to e.g

header('Location: page.html');

not

header('Location:page.html');
or
header('Location : page.html');

take note.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.