PWA Cookie does not survie restart - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Monday, November 6, 2023

PWA Cookie does not survie restart

My backend uses PHP. I set a cookie with:

if(isset($_COOKIE['syncmarks'])) 
    error_log(8,'Cookie is available');
else
    error_log(8,'Cookie is not set');

$days = 30;
$expire = time()+60*60*24*$days;
$options = array (
    'expires' => $expire,
    'path' => null,
    'domain' => null,
    'secure' => true,
    'httponly' => true,
    'samesite' => 'Strict'
);
setcookie('cookiename', 'somedata', $options);

if(isset($_COOKIE['syncmarks'])) 
    error_log(8,'Cookie is available');
else
    error_log(8,'Cookie is not set');

I "install" the PWA via Firefox on Android, but i see the same behavior with Chrome. If i start the PWA from the Homescreen. After the first start, i see in the PHP Logfile:

Cookie is not set
Cookie is available

After closing the PWA, i start it again. Now i expected something like:

Cookie is available
Cookie is available

But i get again:

Cookie is not set
Cookie is available

With that, i assume, the Cookie has not survived the restart. What do i make wrong?

BTW: Using a standard browser application works as expected. The second output is:

Cookie is available
Cookie is available


source https://stackoverflow.com/questions/77427271/pwa-cookie-does-not-survie-restart

No comments:

Post a Comment