[solution][snipplet] Phpbb3 force user to logout PHP functions/code

By.

min read

My profile

Share this:

A function to remove cookies ( and logging out )

[code:1:59bd44ec1b] /**
* Ramon Fincken, for 99% borrowed from phpbb3 code
* Will not delete cookies for search engine bots ( $user->bots )
*/
function delete_cookies()
{
global $config,$user;
$set_time = time() – 31536000;

if($user->is_bot) return;
foreach ($_COOKIE as $cookie_name => $cookie_data)
{
$cookie_name = str_replace($config[’cookie_name’] . ‘_’, ”, $cookie_name);

// Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_
if (strpos($cookie_name, ‘poll_’) !== 0)
{
$user->set_cookie($cookie_name, ”, $set_time);
}
}

$user->set_cookie(’track’, ”, $set_time);
$user->set_cookie(’u’, ”, $set_time);
$user->set_cookie(’k’, ”, $set_time);
$user->set_cookie(’sid’, ”, $set_time);

// We destroy the session here, the user will be logged out nevertheless
$user->session_kill();
$user->session_begin();
}[/code:1:59bd44ec1b]

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *