There are a few issues.
One
Perhaps because by default there is only one session per browser. It's not per tab, or per url.
So, once you have run, the session already has the last_login_timestamp. It then uses the same value for the second session.
If you want them to be different then you have to use different session ids for the two paths.
Another way is to clear/reset the session at the start of the file.
Yet another is to use a different test variable such as test1 and test2.
Two
test is never getting set, and the value of last_login_timestamp is null. I am assuming that you are setting test elsewhere. So, for testing, here is the updated code. The ?? operator ensures that the value goes to time when it is null
<?php
session_start();
if(isset($_SESSION["test"]))
{
$last = $_SESSION['last_login_timestamp'] ?? time();
if((time() - $last) > 900)
{
header("location:../test_log1.html");
}
else
{
echo 'Has not timed out';
}
}
else
{
$_SESSION["test"] = 'xx';
header('location:../test_log2.html');
}
?>
If you want three independent sessions then you have to use different session_ids or just different variables. So use test_p and last_login_timestamp_p for directory p, etc.
Three
PHP is a server side language. When run, nothing is sent to the browser, except the redirect, or echo from this code above.
Once the session variable is set, and 15 mins later you run the code, it will time out in both places. This will keep happening from then on, until the session variable is cleared.
However, it can not time out on the browser and go to a different page by itself, after 15 mins. For that you need to use javascript.