This is my solution for prevention of multiple logins
with grigri's helper function.

have fun , jyrgen

users_controller.php
...
// ... password validation succeeded ....
...
// custom session garbage collection
//
$sessions = $this->Mysession->findAll();
foreach($sessions as $session){
        if($session['Mysession']['expires']<time()){
                $this->Mysession->del($session['Mysession']['id']);
                }
        }

// check to see, if account is in use
//
$account_in_use = false;
foreach($sessions as $session){
        // now traverse trough all existing sessions
        $data = $this->decode_session_data($session['Mysession']['data']);
        if(isset($data['User']['id']) && isset($data['User']['logged_in'])){
                if($data['User']['id']==$someone['User']['id'] && $data['User']
['logged_in']==1){
                        $account_in_use = true;
                        break;
                        }
        }

if($account_in_use === true){
        $this->Session->setFlash('account is active, please try again
later.');
                $this->set('error', true);
                }

else{

    // ok, register user in the session and forward him to a landing
page...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to