← PHP / Laravel · 目录

PHP-024 / 中级

登录后未重新生成会话 ID(会话固定)

A07:2021 Identification and Authentication Failures · CWE-384 Session Fixation

为什么存在问题?

攻击者设置的会话 ID 在认证后继续有效。

如何修复

php
if (Auth::attempt($creds)) {
    $request->session()->regenerate();   // 更换会话 ID
    return redirect()->intended('/home');
}

延伸阅读