odan / session

A middleware oriented session handler for PHP and Slim 4+
https://odan.github.io/session/
MIT License
58 stars 11 forks source link

Check session before start? #2

Closed diwms closed 5 years ago

diwms commented 5 years ago

Hi, I would like to contribute to this package. I use this package in pair with slim/framework and slim/flash packages.

In my case the problem in SessionMiddleware - i got notice from php that session is already started. It's because registering in dependency injection container slim/flash package assume that session is started and ready to work.

So, my idea is - improve a little bit SessionMiddleware by wrapping session start

- $this->session->start();
+ if ($session->isStarted() === false) { 
        $session->start();
}

What do you think? In case of approve I'll open PR with changes.

odan commented 5 years ago

I think that makes sense and would be a good improvement. Please create a PR.