kevinm40
266
3
Spark

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

Posted 1 year 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' => [
            'Laravel\Spark\Listeners\Subscription\CreateTrialEndingNotification',
            'App\Events\SendWelcomeEmail',
            'App\Events\JustRegisteredTracking',
        ],

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
@endif

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.