Call 'wp_logout' when cookie expires (php or javascript) - 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.

Tuesday, December 7, 2021

Call 'wp_logout' when cookie expires (php or javascript)

I am looking for a way to call wp_logout (server side) if my wordpress_logged_in_HASH cookie expires. Unfortunalty I can't find any solution so far. Did a lot of research on stackoverflow and google, but still not done. Does anyone have some advices or ideas how to do it?

Server side I can check if the cookie exits with $_SERVER['HTTP_COOKIE']. The variable exits on my shared server and this works. But how to run wp_logout automaticly when cookie expires? Maybe by some javascript?

if(strpos($_SERVER['HTTP_COOKIE'], 'wordpress_logged_in') == true){
    echo "Login cookie exists!<br>";
    var_dump($_SERVER['HTTP_COOKIE']);
    //echo($startTime = microtime(true));
} else{
    echo "Login cookie not exists!";
    var_dump($_SERVER['HTTP_COOKIE']);
    }


source https://stackoverflow.com/questions/70250036/call-wp-logout-when-cookie-expires-php-or-javascript

No comments:

Post a Comment