Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 711877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:47:07+00:00 2026-05-14T04:47:07+00:00

Could anybody brief about user_token functionality in Auth module? What is a use and

  • 0

Could anybody brief about user_token functionality in Auth module? What is a use and how this incorporates in Auth module?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:47:08+00:00Added an answer on May 14, 2026 at 4:47 am

    It is used when a user checks the ‘Remember me’ box on your site. A token is generated for the user and stored in the user_tokens table.

    If you look at the Kohana_Auth_ORM class in the _login function, you can see how it is created:

        if ($remember === TRUE)
        {
            // Create a new autologin token
            $token = ORM::factory('user_token');
    
            // Set token data
            $token->user_id = $user->id;
            $token->expires = time() + $this->config['lifetime'];
            $token->save();
    
            // Set the autologin cookie
            cookie::set('authautologin', $token->token, $this->config['lifetime']);
        }
    

    It is used by the auto_login() function also in the Kohana_Auth_ORM class:

    /**
     * Logs a user in, based on the authautologin cookie.
     *
     * @return  boolean
     */
    public function auto_login()
    {
        if ($token = cookie::get('authautologin'))
        {
            // Load the token and user
            $token = ORM::factory('user_token', array('token' => $token));
    
            if ($token->loaded() AND $token->user->loaded())
            {
                if ($token->user_agent === sha1(Request::$user_agent))
                {
                    // Save the token to create a new unique token
                    $token->save();
    
                    // Set the new token
                    cookie::set('authautologin', $token->token, $token->expires - time());
    
                    // Complete the login with the found data
                    $this->complete_login($token->user);
    
                    // Automatic login was successful
                    return TRUE;
                }
    
                // Token is invalid
                $token->delete();
            }
        }
    
        return FALSE;
    }
    

    It is up to you to correctly use this capability within your authorization controller. I’m relatively new to Kohana, but I perform a simple check to redirect a user if they go to the login form and are already logged in or can automatically login:

    if (Auth::instance()->logged_in() || Auth::instance()->auto_login())
        Request::instance()->redirect('auth/');
    

    The code for the Auth module isn’t too difficult to understand. If you’re new to Kohana, it’s a good starting point to see how the ORM module works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody please explain how this could possibly happen? I am completely aware of
Could anybody help me to list Some Good Sites that are describing about Complete
could anybody possibly give me some pointers as to the appropriate method to use
Could anybody help with this? I am trying to integrate a coupon function into
Could anybody tell me how I can override HashSet's contains() method to use a
This code prints out MyUrgentException . Could anybody explain why? class MyException extends Exception{
Could anybody tell me about webservice or any RSS feed which wil return Latitude
Could anybody explain what's the problem with listeners in this code? I just started
I am new to PostgreSQL. Could anybody please correct this query. BEGIN TRANSACTION; BEGIN;
Could anybody help me to understand this issue? The problem is: I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.