p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

proasp_codeclinic thread: Verifying a login with cookies

Message #1 by "Travis Nagler" <travisnagler@h...> on Mon, 10 Sep 2001 21:35:32

I think you better use a loginform (login & passwd)
You can put a checkbox there too, for memorising the login (as in
If the box is checked, write the userid, login, passwd etc to a cookie

If someone logs in, check for a particular cookie (with username/login and
password in it, not only login)
verify the data with the data in your database, set a session-var to the ID
of the user if passwd is correct, and go on.
If that cookie is not present, give the login-form.
(no need to check for Request.ServerVariables("HTTP_COOKIE"))

This is the way i usualy work

Steven Broos
        Project Developer

Netural Design - Web Development and Graphical Design - Antwerpse Steenweg
124, 2640 Aartselaar
netural.be <http://www.netural.be/>  - Tel.: +xx xxx xx xx xx - Fax.: +xx x
238 64 22

-----Original Message-----
From: Travis Nagler [mailto:travisnagler@h...]
Sent: maandag 10 september 2001 21:36
To: Code Clinic
Subject: [proasp_codeclinic] Verifying a login with cookies

I have a problem with using cookies to verify a login to a course. I run a
site for a university where students can login and leave messages on a
message board for everyone else. Cookies are supposed to be enabled for
the site to work. It seems the first time you login, whether or not you
have cookies enabled, the code returns an error, saying that cookies have
been disabled, even though they're not. Then you click "Click here to try
again", it goes back to the login screen, and then when you re-enter the
info, it works the second time. It seems a pretty simple thing to check by
using request.servervariables to see if cookies are enabled, but then why
isn't it working properly? I have included the code, but shortened up the
non-relevant text. Currently, I have taken this code out so that it will
work without checking the cookies to see if they are on, but I would like
the code to work with it in there.


' ****** Test for cookies ******

' Set temporary cookie
Dim cookie_test
cookie_test = Request.ServerVariables("HTTP_COOKIE")

' If user supports cookies, proceed with login
If cookie_test <> "" or cookie_test <> null then

     (other asp here if cookies set)

' If user does not support cookies

     (other asp if cookies not set)

End If



  Return to Index