Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Duffleman's avatar

Setting my own Session Keys in Laravel

Edit: Nevermind


I want to extend the Session manager of Laravel so I wrote in a ServiceProvider:

Session::extend('custom-session', function () {
    return new CustomSessionHandler();
});

However, I want to be able to generate my own Session tokens/keys/ids as well, rather than have Laravel build them. This seems to be from the \Illuminate\Session\Store class, in the generateSessionId() function.

protected function generateSessionId()
{
    return sha1(uniqid('', true).Str::random(25).microtime(true));
}

Is there a way I can build my own Store class that extends this one and override this method? Or is there a better way of doing it?

Many thanks

0 likes
0 replies

Please or to participate in this conversation.