Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Session and JavaScript window.location.replace

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.

like image 624
Eae Avatar asked Feb 16 '26 10:02

Eae


1 Answers

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.

like image 78
Elliot Bonneville Avatar answered Feb 18 '26 23:02

Elliot Bonneville