lara21529's avatar

StartSession on new app

I've just created a new Lumen app, first time using it, and everything is working fine.

I've then uncommented the StartSession line in middleware, but I get the error:

Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() must be an instance of Symfony\Component\HttpFoundation\Response, string given

With the string being the html for the welcome page from $app->welcome();

I can't seem to find any resolution for this anywhere so any help would be much appreciated.

0 likes
1 reply
phildawson's avatar
Level 26

@TheSteed Well the addCookieToResponse method in the Illuminate\Session\Middleware\StartSession class is wanting a Response object as the first param. To return a Response object for a string the quickest way is with the response helper function.

$app->get('/', function() use ($app) {
    return response($app->welcome());
});

Please or to participate in this conversation.