jordand78 Posted March 29, 2011 Share Posted March 29, 2011 i have added a member area to my wordpress site. everything works good, login, edit, delete, etc. But when i upload the logout.php file to the godaddy server, it starts logging me out on every page. The programs work fine without the logout file, but as soon as it is uploaded it keeps logging out. here is the logout.php i am using <?php // If the user is logged in, delete the session vars to log them out session_start(); if (isset($_SESSION['user_id'])) { // Delete the session vars by clearing the $_SESSION array $_SESSION = array(); // Delete the session cookie by setting its expiration to an hour ago (3600) if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 3600); } // Destroy the session session_destroy(); } // Delete the user ID and username cookies by setting their expirations to an hour ago (3600) setcookie('user_id', '', time() - 3600); setcookie('username', '', time() - 3600); // Redirect to the home page $home_url = 'http://' . $_SERVER['HTTP_HOST'] . '/my-account/'; header('Location: ' . $home_url); ?> i have looked around the internet but haven't found any solutions. Please help. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/232046-when-i-upload-logoutphp-to-server-it-logs-me-out-on-every-page/ Share on other sites More sharing options...
linus72982 Posted March 29, 2011 Share Posted March 29, 2011 I would go through and check your index file and make sure you aren't accidentely calling the logout script when you shouldn't. I've had conditionals that did this before that were written incorrectly and called things when I didn't intend them to. If you have a header file, check that too as it seems more likely it's in a header that is included at the top of every page. I'm not sure why it wouldn't do it on local testing but would when uploaded, maybe the logout script was in the incorrect directory on the local side? Assuming everything is kosher with the actual code and conditionals, etc, the only thing i can think of is that godaddy has some weird configuration dealing with files named logout. Doesn't make sense, but I guess anything is possible. Try changing the name of the file and all the references, of course? I'm willing to bet it's an accidental call to logout in the code. Quote Link to comment https://forums.phpfreaks.com/topic/232046-when-i-upload-logoutphp-to-server-it-logs-me-out-on-every-page/#findComment-1193679 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.