Top Poster
#1 ramon fincken 401
#2 Site admin 3
#3 Ber|Art 2
#4 braddmark 1
#5 accentmedia 1
#6 Xarzu 1
#7 pEcosespedex 1
#8 khadish 1
#9 moxxx 1
#10 nistelrock 1
[solution][snipplet] Phpbb3 force user to logout PHP functions/code



Rating : 3 / 5

 
Post new topic   Reply to topic    Ramonfincken.com Forum Index -> PHP coding
Beta
Want to be notified by email when this topic gets a reply?  
View previous topic :: View next topic  
Author Message
ramon fincken
Site's programmer

Get a free globally recognized avatar
It's free!


Joined: 03 Aug 2007
Posts: 401
Location: A'dam/Diemen, The Netherlands

PostPosted: Fri May 15, 2009 7:59 pm    Post subject: [solution][snipplet] Phpbb3 force user to logout PHP functions/code Reply with quote

Here you go !

Code:
   $user->session_kill();
  $user->session_begin();



This code may also be of interest to integrate all bits and pieces:
Code:
define('IN_PHPBB', true);
$phpbb_root_path = $include_prefix .'./';  // Your path here
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
Back to top
View user's profile Send private message Visit poster's website
Google adsense
Advertisement





PostPosted: Fri May 15, 2009 7:59 pm    Post subject: [solution][snipplet] Phpbb3 force user to logout PHP functions/code

Advertisement
Back to top
GravityForms
Advertisement





PostPosted: Fri May 15, 2009 7:59 pm    Post subject: [solution][snipplet] Phpbb3 force user to logout PHP functions/code

Advertisement
Gravity Forms Plugin for WordPress
Back to top
ramon fincken
Site's programmer

Get a free globally recognized avatar
It's free!


Joined: 03 Aug 2007
Posts: 401
Location: A'dam/Diemen, The Netherlands

PostPosted: Sun Jun 07, 2009 9:02 pm    Post subject: Re: [solution][snipplet] Phpbb3 force user to logout PHP functions/code Reply with quote

A function to remove cookies ( and logging out )


Code:
  /**
   * 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();     
  }
Back to top
View user's profile Send private message Visit poster's website
Post new topic   Reply to topic    Ramonfincken.com Forum Index -> PHP coding All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
General forums
The world of freelance
Programming
Other projects
Poll
I love gifts

Yes goodies and presents! [3]
No but I love polls ! [1]

Related google ads