I need to know if the user is logged in using Javascript (jQuery) to run some commands (purely aesthetic). The fastest alternative I found was creating a hidden input
that is only placed on the page if the user is logged in (verified through PHP) and check by jQuery if that input
exists. But when I put the code below inside a $(document).ready()
along with other functions, none of them work anymore, all my jQuery goes to the bag. Here is the code:
$(document).ready(function()
{
.
.
.
if ($("#estoulogado").length)
{
$("#email").prop('disabled', true);
if ($("#estoulogado").attr('faoulo') == "fabrica")
{
$("#lojas").prop('disabled', true);
$("#selectdepartamentos").prop('disabled', true);
$("#nome").prop('disabled', true);
};
else if ($("#estoulogado").attr('faoulo') == "loja")
{
$("#fabrica").prop('disabled', true);
$("#selectlojas").prop('disabled', true);
};
};
.
.
.
});
Opening the console (as suggested by Renan) I encountered a syntax error on this line:
$("#email").prop('disabled', true);
The error is as follows: Uncaught SyntaxError: Unexpected token (
No matter what I put inside if
, all my code hangs, it does not work. Why does this occur? I also accept a better idea than this one to check if the user is logged in.