Search code examples
laraveljwtlumen

Set expire time in lumen jwt token


I create an authentication api with jwt and Lumen.

I use tymondesigns/jwt-auth package in my Lumen project for authentication. In project when users logon I want to expire user token after 1 month.

Now how can i fix it?


Solution

  • If you ran:

    php artisan vendor:publish

    as per the installtion wiki: https://github.com/tymondesigns/jwt-auth/wiki/Installation

    Then simple change the ttl setting:

    // In config/jwt.php
    
    ...
    
    /*
    |--------------------------------------------------------------------------
    | JWT time to live
    |--------------------------------------------------------------------------
    |
    | Specify the length of time (in minutes) that the token will be valid for.
    | Defaults to 1 hour
    |
    */
    
    'ttl' => 43800, // valid for 1 month
    
     ...