webguync Posted June 20, 2008 Share Posted June 20, 2008 I have a login script that stores a session variable for username, and takes the user to a form. Once the form is submitted, they are taken to a results page. On that page, I want to create a login button that takes them back to the initial login page when they click on it. Would the best way be to create a form with the submit button going to a page with code like this? <?php //start the session session_start(); //check to make sure the session variable is registered if(session_is_registered('username')){ //session variable is registered, the user is ready to logout session_unset(); session_destroy(); } else{ //the session variable isn't registered, the user shouldn't even be on this page header( "Location: http://www.yourdomain.com/login.htm" ); } ?> Link to comment https://forums.phpfreaks.com/topic/111170-logout-button/ Share on other sites More sharing options...
DarkWater Posted June 20, 2008 Share Posted June 20, 2008 Why make a submit button? Just make a link to logout.php. Link to comment https://forums.phpfreaks.com/topic/111170-logout-button/#findComment-570564 Share on other sites More sharing options...
webguync Posted June 20, 2008 Author Share Posted June 20, 2008 I suppose I could do that Link to comment https://forums.phpfreaks.com/topic/111170-logout-button/#findComment-570585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.