yiisoft / session

A session service, PSR-15 session middleware, and a flash message service which helps use one-time messages.
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
17 stars 8 forks source link

Customs session names are broken #45

Closed itkfm closed 1 year ago

itkfm commented 1 year ago

What steps will reproduce the problem?

$v = new \Yiisoft\Session\Session([
    'name' => 'customname',
]);

What is the expected result?

Yiisoft\Session\Session::getName would return $this->options['name] if available (or first check whether there’s an active session) before resorting to session_name().

What do you get instead?

a fresh session and new session cookie each response

Additional info

session_name() always returns PHPSESSID when there’s been no session started yet.

Q A
Version 1.1.0
PHP version 7.4
Operating system Debian GNU/Linux 11
itkfm commented 1 year ago

Why is this a problem?

The first thing SessionMiddleware::process does, is to call ::getSessionIdFromRequest(…) which then results in a call to Yiisoft\Session\Session::getName which will always return "PHPSESSID" at this time

vjik commented 1 year ago

Fixed by #46