Im trying to set a session cookie when someone tries to log in, and the concept is working, but for some reason the new data wont load after just refreshing the page (or using location.refresh() in my case). When a user signs in a session cookie gets added but as i said it doesnt get detected on refresh / reload. But when i close the tab and open it again it works fine.
Php code:
<?php
if (!isset($_COOKIE['__sessionID'])) {
header('location: /login');
} else {
include 'main.php';
}
?>
Js:
socket.on('adminSuccess', function(data) {
setCookie('__sessionID', data.sessionID);
location.reload();
});