Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8978271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:34:14+00:00 2026-06-15T19:34:14+00:00

<a href=PHP/LogOut.php id=LogOut>Log Out</a> the link a#LogOut calls a PHP script that ends all

  • 0
<a href="PHP/LogOut.php" id="LogOut">Log Out</a>

the link a#LogOut calls a PHP script that ends all sessions and responds with data of “You have logged out”.

<?php
    session_start();
    $_SESSION = array();
    if (ini_get("session.use_cookies")) {
        $params = session_get_cookie_params();
        setcookie(session_name(), '', time() - 42000,
        $params["path"], $params["domain"],
        $params["secure"], $params["httponly"]
    );
}
session_destroy();
echo "You have logged out";
?>

Everything works fine except that once you are logged out and returned to the log in page the ‘data/message’ is not being written to the page. I am suspecting this is due to ‘document.location.href’. If I place a ‘console.log( data )’ it flickers in the console for a split second, then disappears when the return page is loaded. How do I get this to run the script, redirect and display a message?

$('a#LogOut').live('click',function(){
    $.ajax({
    type: "POST",
    url: $(this).attr('href'),
    success: function(data){
    var message = $(data).text();
    if (data==="You have logged out") {
    console.log( data );
    document.location.href='/returnedpage.php';
    $('#messageBox').show().html('<ul></li>' + data + '</li></ul>');

 } else {
    alert('not working');
 }
}
  });
  return false;
});

I could re-load the content with the .load function, but this has pissed me off and I want to get it right. Basically, I need the ‘message’ to be written to div#messageBox on the ‘returnedpage.php’ page. TY

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:34:16+00:00Added an answer on June 15, 2026 at 7:34 pm

    Sorry if I am not completely understanding your issue – but you console log prior to the redirect, so you see the data from the console.log. Then you are redirected and that data is gone on the subsequent page.

    Where is #messageBox located, on the current page OR the redirected page?

    1. If on the current page, you’d probably want to put the redirect after this:

      $(‘#messageBox’).show().html(‘

      • ‘ + data + ‘‘);

      And add some delay to it so the user can see the message prior to the redirect.

      2 If you want to message on the redirected page, then my guess is you’d have to pass data at the end of the url as a param..

      document.location.href='/returnedpage.php?thisData=' + data;
      

      And then on the redirected page, grab the name/value pair for “thisData” and then display it.

      Apologize if I am totally offbase to your issue.

      To do number #2 – on the subsequent page you can just do something like:

      *** caveat: this is JUST FOR THIS ONE USE CASE. I am assuming thisData is the ONLY param in the url. 
      

      and in this page, just do this.

      <div id="messageBox" display="none"></div>
      
      <script>
      var url = document.URL;
      var dispData=url.split('thisData=')[1];
      $('#messageBox').show().html(dispData );
      </script>
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I have this echo, echo <a href = 'showdetails.php?name='$name'&type=movie'> </a>; that is working as
    I have a fancybox that ajax calls file.php to get the content to show.
    I created a log out page and calling it through a href link but
    I have an href in HTML that I dynamically produce from a server. I
    I have a href link and I would like it to be clicked when
    I have this href link with text either attivo or non attivo User can
    I have used href link in the flexigrid rows. on Click it takes me
    I have quick question about a herf link in php field. When I try
    I have the following: window.setTimeout(function() { window.location.href = 'file.php'; }, 115000); How can I,
    function changeClient(s) { if(s.value!=0) { document.location.href = map.php?c=+s.value; } I have to assign the

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.