having log out issues when i click the log out button it does not destroy session

StackOverflow https://stackoverflow.com/questions/22162039

  •  19-10-2022
  •  | 
  •  

Вопрос

having log out issues when i click the log out button it does not destroy session so when the log in page loads it still sees that theres a live session and picks up on that heres the log out code for the buttons what is the correct way to code it so it also destroys current session

<?php
// if you need the user's information, just put them into the $_SESSION variable and output them here
echo WORDING_YOU_ARE_LOGGED_IN_AS . $_SESSION['user_name'] . "<br />";
//echo WORDING_PROFILE_PICTURE . '<br/><img src="' . $login->user_gravatar_image_url . '" />;
echo WORDING_PROFILE_PICTURE . '<br/>' . $login->user_gravatar_image_tag;
?>

<div>
<a href= session_destroy();><?php echo WORDING_LOGOUT; ?></a>
<a href="views/edit.php"><?php echo WORDING_EDIT_USER_DATA; ?></a>
</div>

<?php include('views/_footer.php'); ?>

Нет правильного решения

Другие советы

hope this helps.

In your href tag, put another php page and in that php page, do a session destroy and you can redirect using header() once the session is destroyed.

<a href= "logout.php"><?php echo WORDING_LOGOUT; ?></a>

In your logout.php

<?php
session_start();
if(session_destroy()){
    header("Location: index.php");
}
?>

session_destroy(); is a PHP function. Completely different from HTML, My advice:

Then on logout.php:

<?php
session_start();
 if (session_destroy()){
    // redirect if session is sucessfully destroyed: 
     header("Location: page.php/html");
  }else{
    echo "problem Occurred. Please contact the site administrator";
  }

?>

Though, i'm confsued as to why you would have so many defined constants, when you could just simply echo a string.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top