Support the ongoing development of Laravel.io →
Authentication Session
Last updated 7 months ago.
0

add the popup javascript to the html source only if user is not logged in?

Last updated 7 months ago.
0

Or create a mini API to fetch information about the currently logged in user (like http://example.com/api/v1/me) and call it using AJAX. If the user isn't logged in you can send back an error message.

Last updated 7 months ago.
0

Not sure if it'll help anyone but I did end up using AJAX (similar to what crhayes said above).

The AJAX function that will be called looks like this:

public function getLoginStatus()
{
    return Response::json( array( 'status' => Sentry::check() ) );
}
/* getLoginStatus */

The jQuery initialisation looks like this:

jQuery.fn.timer = function()
{
    $.get( "/ajax/login-status", function( data )
    {
        data.status == false ? $( 'li#status').show() : $( 'li#status').hide();
    });
}

Bind the timer to the relevant page element like this:

window.setInterval(function()
{
    $( "li#status" ).timer();
}, 1000);
Last updated 7 months ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.