Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep user logged in

Status
Not open for further replies.

chutney66

Programmer
Jan 20, 2006
11
I would like to keep users logged in (they need to enter their username and password) unless they press a log out button. So even if they shut down the computer and come back the next day, they would still be logged in. Or maybe have a tick box that will say 'keep me logged in for today'?

At the moment, I am using Sessions to handle user logins, but guess I will need to start using Cookies?

I am using classic asp.

I will be grateful for any help!

Ben
 
Thanks Greg,

I've never used cookies before. Do you have any sample code or a rough outline of what I need to do? Or even a link to a site that shows how this can be achieved? I've been searching for some help and haven't had much luck.

Ben

 
Hi guys,

Thanks!

I managed to work it out. It wasn't as complicated as I thought. I set a cookie to expire in 2 hours with a value. If this value matched a login page, then it would let them in.
The code I used was to create the cookie was:

response.Cookies("login")="yes" response.Cookies("login").expires=dateadd("h",2,Now)


The code I used to check was:

if request.Cookies("login")<>"yes" then Response.Redirect("login.asp?status=loggedout")


Thanks,

Ben
 
chutney66,

I encourage you to be very careful in doing this. I usually use FireFox to browse the web. FireFox has an add-on that allows you to modify the cookies stored on your computer. I assume that many (if not all) other browser have similar add ons. With this add-on, I could easily modify the cookie to make it appear as though I am logged in, and that it expires in 2 years instead of 2 hours. It is *ahem* interesting how many site are vulnerable to this type of hacking *cough, cough*.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top