Why would Laravel Sessions fail in just Safari and IE after switching server?

前端 未结 4 1744
甜味超标
甜味超标 2021-01-02 15:48

New VPS server with Webmin, Apache Centos 6, Laravel application and old database schema. All working fine on old shared host, but on VPS for some reason Laravel\'s Session

4条回答
  •  独厮守ぢ
    2021-01-02 16:01

    This is a classic IE/Safari cross-domain/iframe problem.

    Potential fix for Laravel IE iframe cookie problem (worked for me). Just add this to your App::after filter.

    App::after(function ($request, $response){
      $response->header('P3P', 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS"');
    });
    

    You can even specify, for which route you need this header, for me, it was everything beyond /external/, so the code looks liek this:

    App::after(function ($request,$response){
        if($request->is('external/*')){
            // IE iframe cookie fix
            $response->header('P3P', 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
        }
    });
    

提交回复
热议问题