Welcome Guest, Not a member yet? Register   Sign In
Best way for check user is logged in or not
#5

[eluser]tkyy[/eluser]
dont use a crappy premade library, i recommend modifying the sessions class or just use it out of the box with database. all you have to do is set some userdata indicating that person is logged in and create a function likeso in a new library

Code:
/**
     * indicates that this page is internal, it cannot be accessed unless the user
     * is logged in and has verified his or her email address in the event that an
     * unverified or anonymous user attempts to access a page with this in it, they
     * will be redirected to the welcome page and all session items related to them
     * are destroyed
     */
    public function internal()
    {
        $udata        =    $this->ci->session->userdata;
        
        if(isset($udata) && is_array($udata) && isset($udata['verified']) && isset($udata['logged']) && isset($udata['local_key']))
        {
            if($udata['verified']==TRUE && $udata['logged']==TRUE)
            {
                if($this->ci->local->read('local_key')==$udata['local_key'])
                {
                    /* good :) */
                    return;
                }
            }
            
            /* unverified user, show them the confirm page */
            if($udata['verified']==FALSE && $udata['logged']==TRUE)
            {
                redirect('register/confirm');
                return;
            }
        }
        
        /* something was wrong, destroy and redirect to welcome */
        $this->destroy();
        redirect(ospc_base());
        return;
    }


Messages In This Thread
Best way for check user is logged in or not - by El Forum - 05-24-2009, 10:50 PM
Best way for check user is logged in or not - by El Forum - 05-24-2009, 11:09 PM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 04:07 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 04:08 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 04:13 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 04:21 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 04:30 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 04:37 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 05:10 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 05:21 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 06:21 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 06:34 AM
Best way for check user is logged in or not - by El Forum - 05-25-2009, 06:36 AM
Best way for check user is logged in or not - by El Forum - 05-26-2009, 04:52 AM
Best way for check user is logged in or not - by El Forum - 06-09-2012, 05:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB