Jump to content

when i upload logout.php to server, it logs me out on every page


jordand78

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.