1

What's the problem ?

I am facing Token Mismatch issue when accessing the site in IFrame in Internet Explorer.


What I tried so far ?

I search for the resolution and found this link

Below is the code that I found in the above link

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"');
    }
});

What's the question ?

Where should I write the above code in Laravel 5.2 ?

Community
  • 1
  • 1

1 Answers1

0

You should create after middleware and add this middleware to web middleware assuming you use web group middleware for your routes.

Sample middleware:

<?php

namespace App\Http\Middleware;

use Closure;

class FixIeFrameMiddleware
{
    public function handle($request, Closure $next)
    {
        $response = $next($request);

        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"');
        }

        return $response;
    }
}

and now in app/Http/Kernel.php in $middlewareGroups property for web group you should add new array element:

 \App\Http\Middleware\FixIeFrameMiddleware::class,
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • @Helper You have the same problem as PankajGarg ? – Marcin Nabiałek Dec 31 '15 at 21:23
  • hi unfortunately this is not woking. :) –  Dec 31 '15 at 21:31
  • What exactly? Is this middleware executed at all? I haven't verified the method you provided, I've just showed how to create this middleware – Marcin Nabiałek Dec 31 '15 at 21:33
  • I have no issue if I run the site under iframe in Chrome. Issue comes when I run the site in IFrame in Internet Explorer. –  Dec 31 '15 at 21:35
  • Yeah, I get it, but have you verified if this middleware is run at all? That was the question - how to create this middleware :) – Marcin Nabiałek Dec 31 '15 at 21:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/99434/discussion-between-pankaj-garg-and-marcin-nabialek). –  Dec 31 '15 at 22:13