I'm creating a website which has a login function. Once the user logs in, they are shown a button that allows them to log out. When the user logs in, a boolean variable on the server is changed to "true", because the user has logged in. When the user clicks the logout button, the boolean variable changes to "false". My question is, should I be storing this information in a http cookie instead of a variable? (I'm thinking that storing this in a variable on the server might slow down the website.) I'm using this variable for the purpose of letting the user go directly to the website the next time they visit if they haven't logged out, instead of having to login every single time.
shaqtus 0 Newbie Poster
Recommended Answers
Jump to PostThere are pros and cons to using a cookie to store login variables for a website.
Pro:
- Cookies can be set to terminate either at end of session or after a specified time period
- Cookies are relatively easy to write/read
- Cookies are client side and don't require much …
Jump to Postif you are using FormsAuthentication then
write this on page load
if(Request.IsAuthenticated)
// Set Bool variable to true;
else
// Set Bool variable to false;hope that helps.
All 6 Replies
Lusiphur 185 Practically a Posting Shark Team Colleague Featured Poster
shaqtus 0 Newbie Poster
Lusiphur 185 Practically a Posting Shark Team Colleague Featured Poster
shaqtus 0 Newbie Poster
Lusiphur 185 Practically a Posting Shark Team Colleague Featured Poster
dnanetwork 18 Practically a Master Poster Banned
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.