Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect to another php page 1

Status
Not open for further replies.

nickjar2

Programmer
Jun 20, 2001
778
US
Hi

I have searched the forum and I seem to be doing things right, although the following php does not work:

<?php
session_start();
include("vars.php");
$_SESSION = array();
session_destroy();
flush();
header("Location: $self_url?logged-out");
exit;
?>

The self_url points to my home page, but it stays on logout.php (the code is contained in logout.php). I have hard coded my url in but nothing. It stays at logout.php which is so frustrating!!!

Any help greatly appreciated as I am seriously frustated now.

Cheers

Nick

Nick (Everton Rool OK!)
 
what does flush() do? if it sends output to the browser or calls ob_end_flush() then the header function will not work.

instead try ob_end_clean() and then the header redirect should be ok.
 
aaahhhh - I will go and check and let you know.

Cheers 4 the super fast reply :)

Nick (Everton Rool OK!)
 
Thanx very much for that :)

it worked!!!!

I am assuming that flush() is a function. But where could it sit? It isnt in the logout php and there are no includes, so how does it know where do find flush() (or is flush a built in php func?)

php is new to me btw - i am a vba guy.

Cheers again

Nick (Everton Rool OK!)
 
found it cheers!

Flush() is a built in php command

Cheers

Nick (Everton Rool OK!)
 
flush is a php function but not one that i knew of!

the solution is still the same though! of course, if you don't use output buffering that you don't need to worry about the line at all. just take it out.

also you should set the session cookie to expire for a proper session destruction routine (see
Code:
if (isset($_COOKIE[session_name()])) {
   setcookie(session_name(), '', time()-42000, '/');
}
[before the session_destroy() ]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top