Lumen Request has session app('session') is empty. Redirect not working

- 1 answer

Ad

When taking the following store method on a lumen controller

public function store(Request $request, JwtToken $jwtToken, Redirector $redirector)
{
    $sessionData = $request->session()->all();
    $this->validate($request, [
        'username' => 'required',
        'password' => 'required'
    ]);
}

In $sessionData all the data in the session is present including the previous url. When going through the default validator it calls app('session')->previousUrl() which returns null

When doing the same on $request->session() it is present. I have no clue if I messed something up or this is a bug in lumen.

I tried Redis and File driver.

Ad

Answer

Ad

Seems to be a bug in Lumen fixed by doing the following

public function store(Request $request, JwtToken $jwtToken)
{
    $sessionData = $request->session()->all();
    $this->validate($request, [
        'username' => 'required',
        'password' => 'required'
    ]);

    //use global redirect helper function
}

Removed the Redirector reference and used the global helper function

Ad
source: stackoverflow.com
Ad