I have tried to set a cookie in an AJAX request, but it doesn't work the way its supposed to.
I found some valuable help on stack-overflow, but still, I can't get it to work properly.
I know there is many duplicate question ask before, but really I tried all of them.
The links below are the following answers that I've tried:
- Can an AJAX response set a cookie?
- Code Igniter Cookie
- Setting a cookie in an AJAX request?
- php setcookie not working with ajax call
This is the current code that I'm using:
$name = '_user';
$value = "hello";
$expire = time() + 86500;
$domain = '.localhost';
$path = '/';
setcookie($name,$value,$expire,$path,$domain);
These are the screenshots of inspect element it in Mozilla Firefox
and this one in Google Chrome