Support the ongoing development of Laravel.io →
Authentication Session
Last updated 2 years ago.
0

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

Last updated 2 years 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 2 years 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 2 years ago.
0

Sign in to participate in this thread!

Eventy

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.

© 2024 Laravel.io - All rights reserved.