2 years ago

Event firing problem (or just trying to place a cookie on a page)

Posted 2 years ago by kevinm40

After a user has just registered, I need to place a cookie on the /home page of the app, but it must only appear once, on succesful registration.

The approach I have used is to have setting in my app/config of 'justRegistered' => 'false',, then create an event attached to EventServiceProvider with

'Laravel\Spark\Events\Auth\UserRegistered' => [

the handle of the event has:

    public function handle(UserRegistered $userRegistered)
        \Config::set('app.justRegistered', 'true');

which changes the 'false' to 'true'

lastly, in my blade layout I have the following

 @if (Config::get('app.justRegistered')=='true')
// some stuff

The problem is that the setting doesn't change, and stays at false. I have checked that the event is firing correctly on registration, which it seems to be, but the blade template is not picking up on the change.

Any ideas why? Or a simpler approach?

Please sign in or create an account to participate in this conversation.