EmperorJazzy Posted March 31, 2011 Share Posted March 31, 2011 Afternoon all, Quick query; On the index.php page I have a hyperlink entitled LOGOUT. This allows the users to log out of their current session. The hyperlink directs to a logout.php page with the following contents: <?php session_end(); ?> <html> <head></head> <body> <?php header('Location: index.php'); ?> </body> </html> Essentially; the code should end the session and redirect the browser back to the main page. Currently, the hyperlink does redirect to the logout.php page, but; - it doesn't return to the index.php page - if I click the back button, the session is still alive Can anyone assist? Is there a better way of doing this? This isn't something that hasn't been done before, but finding the topic in the forums has been difficult. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/232347-session_end-and-header-issue/ Share on other sites More sharing options...
btherl Posted March 31, 2011 Share Posted March 31, 2011 This manual page has sample code for finishing a session: http://php.net/manual/en/function.session-destroy.php Link to comment https://forums.phpfreaks.com/topic/232347-session_end-and-header-issue/#findComment-1195277 Share on other sites More sharing options...
EmperorJazzy Posted March 31, 2011 Author Share Posted March 31, 2011 Thanks for viewing. Solution found via a post in the forum at the same time as myself. Cheers all. Link to comment https://forums.phpfreaks.com/topic/232347-session_end-and-header-issue/#findComment-1195279 Share on other sites More sharing options...
INeedAGig Posted March 31, 2011 Share Posted March 31, 2011 What are you using to write your code? I just solved the same issue in one of my scripts. It was caused by a BOM (Byte Order Mark) which is an invisible line of code before the initial <?php. PHP will know it's there and process it, which will cause header errors. Link to comment https://forums.phpfreaks.com/topic/232347-session_end-and-header-issue/#findComment-1195280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.