Let’s say your website uses Symfony’s “Friends of Symfony” FOS User Bundle but you also have different internal systems and other ways users can authenticate.  You don’t want to keep pestering the user to log back in, the better solution is to get your authentication system that’s outside the FOS User Bundle to talk to it.

You take extra security precautions, perhaps white list their IP and use some other encrypted cookies values.  Here’s one way you can “refresh” their login if you send the user back to a Symfony controller that falls under the FOS User Bundle’s firewall, which you’ve defined in your Symfony’s security.yml settings file.

So if you can extract the user’s email address from the cookies already set, hopefully through encrypted means, of course, you can essentially log them back in automatically by defining the $user as the object you actually get from the userManager object.

$userManager = $this->container->get('fos_user.user_manager');
$user=$userManager>findUserByEmail($userEmail);

if($user){
   $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
   $this->get('security.context')->setToken($token);
   $this->get('session')->set('_security_main',serialize($token));
}

 

Be sure to add at the top of the controller the use of the the object:  use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;

Learn more from Symfony’s documentation about Authentication.  The above is only one solution, I found the FOS User Bundle is pretty simple and flexible to work with.

Are you looking for experienced PHP, Symfony, WordPress, MySQL, LAMP, or Magento developers?  Perhaps you are looking to modernize your company’s systems, considering going open source, or launching a new e-commerce site?  Contact us and we can connect you to a network of flexible web developer freelancers that matches your organization’s needs and budget.


Setting up in Symfony requires setting time zone, of all things, before you can continue with your new website masterpiece.  This is annoying, especially in shared hosting environments when you might not have access to certain settings.

date.time = “US/New_York”

Here’s a list of American time zones for quick reference.

Why are there so many names?  Decoupling in the web is a principle that applies to virtually everything (pun intended).  One zone description for a time zone doesn’t suffice when different localities within a time zone may abide by DST (Daylight Savings Time) and others don’t.  Go figure.


In Symfony, you don’t always have to actually pass values from your controllers to your Twig views.  Twig can actually pull global and server values directly through the super global “app” variable.  Most frequently, you can access these corresponding objects like Kernel, Request, Security and Session variables like so:

{{app.kernel.cachedir}}
{{app.kernel.logdir}}
{{app.kernel.rootdir}}
 
{{app.request.basepath}}
{{app.request.baseurl}}
{{app.request.uri}}

{{app.security.token.user}}

{{app.session.locale}}

Need more Twig tips?  View our Symfony Twig Cheatsheet!

Looking for a PHP developer, a Symfony expert or WordPress web developer?  Perhaps a business system architect that specializes in scalable MySQL business system design and deployment?  We have reliable, fast and professional developers that meets your organization’s needs!  Contact us for your next web development project and schedule a free consultation today.


It’s inevitable when you install Jetpack that some things on your site will need to be re-updated.  I found this out when I installed Jetpack and couldn’t find the footer overrides so the site was showing the “Proudly powered by WordPress” message at the bottom.

Gotta love Jetpack by WordPress‘s “infinite scroll” feature though — and Jetpack in general is great!

After a little digging, I found the solution.  I only wasted another 10 minutes of my life updating something so small but so necessary.  Again.  Don’t you love how the web has turned us all into overly-anal critics paying attention to things that in normal life elsewhere just plain simply wouldn’t matter?  Yes, the line at the footer of the website that no one reads, when did we all turn into such hollow digital echoes of our real selves?…..  🙂

Here’s the code you need to put in your child theme’s function.php file:

add_filter( 'infinite_scroll_credit', 'my_footer_text' );

function my_footer_text() {
return '<a href="http://linkOrNot">Proudly created not by WordPress, or whatever you want to put in here, everyone knows its WordPress anyway....</a>';
}

 


Go in depth with your security.yml file!  Doesn’t that sound like fun?!

Sensio Lab’s Symfony has a great reference to help developers determine the best settings to properly set up security and login behaviors, like where to redirect users after a successful login, etc:

Security Bundle Configuration

How to customize your form login

 

Click here to contact us if you are looking for a freelance web developer who specializes in PHP, Symfony, WordPress, Magento ecommerce, and MySQL.  We have access to very smart web developer experts that can fit any budget.  Ask about our special non-profit discounts!