Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  27] [ 3]  / answers: 1 / hits: 43316  / 8 Years ago, tue, february 9, 2016, 12:00:00

Is there a safe way to check if the user has logged into the application rather than checking if sid cookie exists in user's machine ?



I want to allow the user to proceed on certain links on a page only if they have logged in.



I do the login validation on the server side but want to avoid the request trip.



Pure JS or JQuery solution would be appreciated.



Thank you.


More From » jquery

 Answers
6

Please try this



Put this code after user first log in



jQuery(window).load(function() {
sessionStorage.setItem('status','loggedIn')
});


When ever user clicks a link you can check like



if (sessionStorage.getItem('status') != null))
//redirect to page
}
else{
//show validation message
}

[#63379] Sunday, February 7, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reesel

Total Points: 345
Total Questions: 124
Total Answers: 119

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
2 Years ago
;