PHP code example of jpm / session-sharing-bundle

1. Go to this page and download the library: Download jpm/session-sharing-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jpm / session-sharing-bundle example snippets


    use JPM\SessionSharingBundle\Service\JpmSessionClient;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    use Symfony\Component\HttpKernel\Event\ResponseEvent;
    use Symfony\Component\HttpKernel\KernelEvents;
    
    class RemoteAuthSubscriber implements EventSubscriberInterface
    {
     public function __construct(
        private JpmSessionClient $remoteAppHelper
     ){}
    
     public function onKernelResponse(
        ResponseEvent $event
     ): void
    {
       $this->remoteAppHelper->watchRemoteSessionRequest($event);
    }
    
    public static function getSubscribedEvents(): array
    {
       return [
          KernelEvents::RESPONSE => 'onKernelResponse'
       ];
    }
    }
   

    use JPM\SessionSharingBundle\Service\JpmSessionClient;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    use Symfony\Component\HttpKernel\Event\ControllerEvent;
    use Symfony\Component\HttpKernel\KernelEvents;
    
    class SessionManagerSubscriber implements EventSubscriberInterface
    {
    
        public function __construct(
            private JpmSessionClient $remoteAppHelper,
        ){}
    
        public function onKernelController(ControllerEvent $event): void
        {
            $this->remoteAppHelper->watchSessionRefresh($event);
        }
    
        public static function getSubscribedEvents(): array
        {
            return [
                KernelEvents::CONTROLLER => 'onKernelController',
            ];
        }
    }