Our web site is built on top of a custom php mvc framework and we wanted to slowly convert each flow (for eg: signups) to Laravel.
So in essence, the existing code and the new code using laravel have to co-exist. But we hit a snag, where session information set by laravel is not availble to the other mvc and vice-versa because of their conventions.
For eg, the custom mvc uses the following.
$_SESSION['AUTH']='TRUE';
While Laravel uses something like this.
Session::put('AUTH', 'TRUE');
We tried to set $_SESSION['AUTH'] = 'TRUE' through laravel classes. But we are not able to access it when control is passed to the older MVC.
I know its complicated, and i should just wait to convert the entire code base to Laravel, and be done with it. But we are a small company with minimal resources. So we dont have the luxury to stop feature development and spend time re-writing using Laravel Exclusively.
So my question is this. How , if by any mechanism, can we achieve this?
Global variables?
Any other suggestions?
I would recommend you to use Laravel's Auth
-Class here, listen to the auth.login
event and set your session flag by hand.
Event::listen('auth.login', function($user)
{
$_SESSION['AUTH']='TRUE';
});
It is the easiest way and you only have to delete the event listener when you completly migrated to Laravel.
I know this is a quick and dirty thing, but after full migration you don't want to use the $_SESSION
ever again to manage your authentication ;) so I think this should be a very good bridge between your new and old codebase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With