简体   繁体   中英

What is Laravel's CSRF Token Pattern?

I want to know how Laravel:

  1. creates CSRF tokens

  2. where it is located

  3. expiration time

When I refresh the web page I see the same token that was already created and how increase or decrease expiration time?

In laravel/vendor/laravel/framework/src/Illuminate/Session/Store.php there is a function called regenerateToken() ( github )

/**
 * Regenerate the CSRF token value.
 *
 * @return void
 */
public function regenerateToken()
{
    $this->put('_token', Str::random(40));
}

It just uses a 40 character long random string as you can see.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM