symfony2 session lifetime

You can set the session expiration time in your config file under the framework section. Mine looks like this: config.yml framework: secret: %secret% charset: UTF-8 error_handler: null csrf_protection: enabled: true router: { resource: “%kernel.root_dir%/config/routing.yml” } validation: { enabled: true, annotations: true } templating: { engines: [‘twig’] } #assets_version: SomeVersionScheme session: default_locale: %locale% cookie_lifetime: 3600 // … Read more

Get Request and Session Parameters and Attributes from JSF pages

You can get a request parameter id using the expression: <h:outputText value=”#{param[‘id’]}” /> param—An immutable Map of the request parameters for this request, keyed by parameter name. Only the first value for each parameter name is included. sessionScope—A Map of the session attributes for this request, keyed by attribute name. Section 5.3.1.2 of the JSF … Read more

What does the crossContext attribute do in Tomcat? Does it enable session sharing?

You can share sessions between web applications by using a Single Sign-On Valve. You would set crossContext=true if you wanted to share some information between different Web Applications in the same Virtual Host. For example app1 would call: setAttribute(“name”, object); and another app could call getContext(“/app1”).getAttribute(“name”); to read the information. If crossContext wasn’t set to … Read more

Authentication: JWT usage vs session

JWT doesn’t have a benefit over using “sessions” per se. JWTs provide a means of maintaining session state on the client instead of doing it on the server. What people often mean when asking this is “What are the benefits of using JWTs over using Server-side sessions“. With server-side sessions, you will either have to … Read more

Session variable value is getting null in ASP.NET Core

For ASP.NET Core 2.1 and 2.2 In the ConfigureServices method of the Startup class, Set options.CheckConsentNeeded = context => false; as follows: services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => false; options.MinimumSameSitePolicy = SameSiteMode.None; }); Problem solved!

How to log users off automatically after a period of inactivity?

You have to implement it with a kernel listener, this is the way I solve it: Listener src/Comakai/MyBundle/Handler/SessionIdleHandler.php namespace Comakai\MyBundle\Handler; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; class SessionIdleHandler { protected $session; protected $securityToken; protected $router; protected $maxIdleTime; public function __construct(SessionInterface $session, TokenStorageInterface $securityToken, RouterInterface $router, $maxIdleTime = 0) { … Read more