I am trying to logout users when they hit a particular path in the website and log them back in to renew the session(because it has its own login session and its expiry is not in sync with the actual website). So I have the below code. I am logging into website but when I clicked the page(path:/mypath/page) its logging me out in a loop and I am getting redirect too many times error, when I checked for the cookie 'simplesamlphp_cookie' its not present, how do I create the cookie, when I create the cookie through chrome javascript the logic wrks.So, I need to know how to create the cookie

public function samlRedirect(GetResponseEvent $event) {
    $path = $this->currentPath->getPath();
    $request = $event->getRequest();
    $host = $request->getHost();
    if($path === '/mypage/path' && !($request->cookies->has('simplesamlphp_cookie'))){
    if (!$this->simplesaml->isAuthenticated()){
       $expiry = time() + (200);
       $cookie = new Cookie('simplesamlphp_cookie', '1', $expiry, '', '', '', '');
       $response = new RedirectResponse('/saml_login?ReturnTo=https://' . $host . $path);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.