Checking for existence of a cookie

G

GailS

I tried to post this last week, but never saw it, so I hope it's not a
duplicate. (Sorry if it is.)

I am rewriting our member log-in page in classic ASP from PHP. We will be
switching platforms next month. Every member has an access number to log in.
Once they have logged in, if they accept it, a cookie is provided so they do
not have to log in again. When the code is supplied via the cookie or form,
it is validated against a database file to determine the level (customer,
distributor, etc.) and the page is built accordingly. If the code has been
inactivated or is no longer valid, appropriate messages are supplied. Pretty
basic stuff.

The first thing I want to do is to check if the cooky exists on the client
computer. PHP had code for this, but I'm not sure I'm doing it correctly in
classic ASP. My opening code is below. This is before any HTML on the page,
as I have to determine if cookeis need to be set or deleted before the page
opens. When I run this on my IIS server here, the page displays an error 500,
but no hints as to what line the error is in. Can anyone help. I suspect it
is because at this state, the cookie does not exist, as it is my first
log-in. Thanks in advance.

If Request.Cookies("kc").HasKeys Then
bCooky = "S" 'Cookie exists, set flag for cooky set
strCode = Request.Cookies("code")
strSource = "cookie"
ElseIf Not IsEmpty(Request.Form("code")) And Not
IsEmpty(Request.Form("submit")) Then
strCode = Request.Form("code")
strSetCooky = Request.Form("cooky")
strSource = "form"
End If
 
B

Bob Barrows [MVP]

GailS said:
I tried to post this last week, but never saw it, so I hope it's not a
duplicate. (Sorry if it is.)

I am rewriting our member log-in page in classic ASP from PHP. We
will be switching platforms next month. Every member has an access
number to log in. Once they have logged in, if they accept it, a
cookie is provided so they do not have to log in again. When the code
is supplied via the cookie or form, it is validated against a
database file to determine the level (customer, distributor, etc.)
and the page is built accordingly. If the code has been inactivated
or is no longer valid, appropriate messages are supplied. Pretty
basic stuff.

The first thing I want to do is to check if the cooky exists on the
client computer. PHP had code for this, but I'm not sure I'm doing it
correctly in classic ASP. My opening code is below. This is before
any HTML on the page, as I have to determine if cookeis need to be
set or deleted before the page opens. When I run this on my IIS
server here, the page displays an error 500, but no hints as to what
line the error is in.

The first thing you have to do is determine what the real error is:
http://www.aspfaq.com/show.asp?id=2109
 
G

GailS

--
Gail S
Gent-l-kleen Products, Inc.
York, PA


Bob Barrows said:
The first thing you have to do is determine what the real error is:
http://www.aspfaq.com/show.asp?id=2109

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Bob,

Many thanks! When I started working with ASP two years ago, I got the
detailed script errors, which were very helpful. But I was unable to continue
that work for some time now. The IE setting must have been reset with the
last version upgrade, as now I have my debugging notes back. It's not the
cooky line, silly me forgot to remove a directory reference for an included
file. OOPS! Again, thanks so much!

Gail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top