can't get php's $_SESSION to work on my local machine
it's working just fine on a live server but it's not working on a local machine
i have tried with apache and php on windows, apache and php on mac and apache and php on debian, none of them work ( my live server is also running debian 9, the same one i tried locally )
in firefox' developer tools > network > headers i can see that php is sending the set-cookie but for some reason it's not being set ( no cookies in storage > cookies, and my script isn't working as it should when cookie is set )
i'm not using ssl/https and i have set "session.cookie_secure = 0 and off" but for some reason this is what the set-cookie header looks like: "Set-Cookie: PHPSESSID=XXXXX;path=/;HttpOnly;Secure", i don't think php should be setting the Secure flag since i explicitly disabled it in php.ini?
and yes, every file that uses session functionality has a session_start() in it
there are no apache/php errors whatsoever, i even have xdebug enabled
tested using localhost, 127.0.0.1, 10.0.0.10 ( my lan ip ), and custom hostname, none work
i'm out of ideas, tried everything i could think of
works on a live debian 9 server with php 7.2 and default configuration
doesn't work on a local debian 9 server with php 7.2 and default configuration
doesn't work on windows with the same apache/php versions
doesn't work on mac with apache 2.4 and php 7.3, not even with session.cookie_secure=0 set
checked for both apache and php errors, there are none
used firefox' developer tools to see headers/cookies
checked my code and made sure it has session_start() and everything else is correct
i even tried manually setting the cookie with the secure flag set to false and again "Secure" is being set in Set-Cookie header, this was the code:
setcookie("PHPSESSID", "7nhqdim7uu2viae7vhhf9os5ue", 0, "/", "", false, false);
and here is the code i use for testing:
<?php
session_start();
var_dump($_SESSION);
if(isset($_POST['submit']))
{
$_SESSION['value'] = $_POST['example'];
header('Location: /session.php'); // session.php is this file
}
if(isset($_SESSION['value']) && $_SESSION['value'] == 'example')
{
echo "value is " . $_SESSION['value'] . '<br>';
}
?>
<form method="post">
<input type="text" name="example" value="example">
<input type="submit" name="submit" value="submit">
</form>
if
block dovar_dump($_SESSION['value']);
and tell us what you got? – Anant Kumar Singh