3

My use of:

window.location.replace("calendar.php");

Seems to be not working at all with my PHP session variables. When I use this call I can not use the back button with my code:

<?php
  session_start();

  if($_SESSION['loggedin'] != TRUE) {
    header("Location: index.php");
  }
?>

Does anyone know why this may be? Thanks.

2
  • 1
    Did you read the documentation? The whole point of a replace would be to replace an instance in window.history, so the last page would be replaced with the new one, and the back button would no longer work the way it usually does. Commented Dec 14, 2012 at 5:03
  • You are right, but it's not helping him ! Commented Apr 28, 2015 at 21:52

2 Answers 2

2

I think you want window.location.href = "calendar.php"; instead. That should hang on to your session variables, as well as not breaking the back button.

Sign up to request clarification or add additional context in comments.

Comments

0

This is why you do have :

  • window.location.replace("calendar.php");

but also

-window.location.assign("calendar.php");

the first one might clear the session while the second will keep it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.