I have a cookie set to record an admins location so if they session time out they can access the page they were last on upon re-login or if I send them a link they can log in and be redirected to the page I sent them instead of the dashboard. The cookie does appear to be present in the browser with a couple others I have set.
However when I check to see if the cookie exists with $_COOKIE["AdminPage"]
it always comes up empty.
When I do a var_dump
of the $_COOKIE
array I get:
array (size=2)
'PHPSESSID' => string '4f7949bde665b3ceae66624b3ecb6afe' (length=32)
'Sirius' => string 'sY80fAjJm93OHtfj'... (length=1145)
There should be at least two more cookies in the var_dump. One named AdminPage
and one named locked
according to my console. My console is as below:
Console Cookies
---------------
Name | Value | Domain | Path | Expires | Size | HttpOnly | Secure | SameSite | Last Accessed |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AdminPage | https%3A%2F%2Fdsm.example.ca%3A443%2Fsystem%2Fsettings%2Fsaved%2F | .example.ca | / | Tue, 19 Jan 2021 03:40:50 GMT | 78 | true | true | Lax | Sun, 20 Dec 2020... |
locked | 1 | dsm.example.ca | / | Session | 7 | false | false | Lax | Sun, 20 Dec 2020... |
PHPSESSID | 4f7949bde665b3ceae66624b3ecb6afe | .example.ca | / | Session | 41 | false | false | None | Sun, 20 Dec 2020... |
Sirius | LRF6aQDwY1kEVR9o5j6xubt4LFW09yZaNAzst5GhqpDvypriKlZ4agJTqnkF2 ... | .example.ca | / | Tue, 19 Jan 2021 03:40:50 GMT | 1151 | true | true | Lax | Sun, 20 Dec 2020... |
The AdminPage
cookie is set via the code blow and all cookies are set in a similar matter, except the locked
cookie which is set via JavaScript. (It is not too important if the locked
cookie is available in PHP)
$arr_cookie_options = array (
'expires' => strtotime( '+30 days' ),
'path' => '/',
'domain' => '.'.$data["domain"], // leading dot for compatibility or use subdomain
'secure' => true, // or false
'httponly' => true, // or false
'samesite' => 'LAX' // None || Lax || Strict
);
setcookie("AdminPage",$this->currentPage(),$arr_cookie_options);
I also noticed in my console:
Cookie “locked” has been rejected because it is already expired.
Cookie “AdminPage” has been rejected because it is already expired.
If the rejection is why I cannot access those two in PHP then why are my cookies getting rejected? I set the Sirius
cookie exactly the same as the AdminPage
except for the name and value so why is it not being rejected?
I am using FireFox if that's making a difference and my hosting is shared so editing the .ini
is out of the question should one feel it may be required.