Home > Software design >  laravel session cookie not being set
laravel session cookie not being set

Time:03-26

I recently moved my website to a new server ( both are apache ). the problem is that in this new server, the session cookie is not being set ( in addition to the XRF-token cookie ). but in my older host, they are just being set perfectly. and I also noticed that the set-cookie header is not present ( but in the older host is present. )

Note that hosting moved my entire home directory, so none of my files have changed and the database ( my session driver ) works fine and stores sessions.

but cookies are not being set and as a result of that, I get 419 errors from the login page and other POST requests.

is there any configuration that I have to do in my new cPanel host or is there anything you think that I missed? also tried clearing the cache and regenerating the app key. nothing worked.

CodePudding user response:

Session cookies may not be sent by Apache if some stray characters are output before the headers. This can happen if a file contains some text before the opening <?php. It can also happen (but less likely) if you close files with ?> This is bad practice and should be avoided.

You would need to check your files carefully.

You may be able to check if this might be the case by looking at the response from the server in your browser developer tools and see if there are any characters before what you would expect to be the first bytes of the response (eg <html )

  • Related