Check if Symfony PHP session has been started

Here’s how you can check if a session in Symfony was started:

if ($this->get('session')->isStarted()){

    // Session has been started, so do stuff here
}

Not a big fan of session variables, but used for non-sensitive session data, I think sessions are still useful.  After all, if you only want certain behaviors on your website tailored to a customer apply only while their browser is open on your site, this is an efficient way to pass certain settings and values along with a small footprint since all sessions go to garbage upon the visitor’s browser being closed.

 

About Author:

Senior Cloud Software Engineer and 25+ years experienced video production, video editing and 3D animation services for a variety of global clients including local video production here in Jacksonville, Florida.

Leave a Comment

Your email address will not be published. Required fields are marked *