Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A Checking if the user is signed in from front end code

1 answer  ·  posted 1y ago by trichoplax‭  ·  last activity 1y ago by ArtOfCode‭

#1: Initial revision by user avatar trichoplax‭ · 2023-01-10T19:42:43Z (over 1 year ago)
Checking if the user is signed in from front end code
When writing front end code for QPixel, is there a preferred way to check whether the user is signed in?

The back end code has access to this information, and constructs the page accordingly. Some page elements are present or not based on whether the user is signed in.

The front end code could check for the presence of an element that is only present when the user is signed in, but this seems brittle - any changes to the naming or presence of elements in future could break the check and make it look like the user is not signed in when they are.

Is there a variable passed to the front end specifically for the purpose of checking whether the user is signed in? If there is not yet, would it be useful to create one? Is there a particular place in the HTML structure that would be best to place such a variable? Is there a convention for this?