How to fix: Object doesn't support this property or method: 'response.Cookies(...)' (ASP classic, VBScript))

After reading ... did this article help solve your problem?

  • Yes.
  • No.
See results without voting

How to fix the Microsoft VBScript runtime error "Object doesn't support this property or method: 'response.Cookies(...)'" - It could be SUPER easy.

I ran across this nasty vbscript runtime error when I was building a phone number tracking programming in ASP (classic, not .net). I did some searching, but could not find an answer to my question. So, I did some trouble shooting and found the answer. It is SO EASY. My solution may not always be the case, but it might work for you.

Here is what my error looked like

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'response.Cookies(...)'


I'm relatively new to using Cookies, and Session Variables, and I was certain my cookie had values ... here was the problem

I know you're a programmer reading this article, so I'm not going to be very verbose about it, I'm going to just try to show you the answer, but a little bit of explanation is often required, and appreciated by fellow programmers.

I was using some IF THEN logic, to check to see if a Cookie variable was being set.

This vbscript (ASP) code snippet was producing the error:

...

if request.Cookies("ssnVisitor").HasKeys then 'primary visitor tracking logic
    'customer has received our cookie
    'locate record
    'read and compare record
    'assign display variables
    'modify record
else
    if response.Cookies("ssnVisitor")("tracking_active")<>"yes" or session("tracking_active")="yes" then 'secondary logic
            if response.Cookies("ssnVisitor")("display_number")<>"" then
                displayNumber=response.Cookies("ssnVisitor")("display_number")
            else
                displayNumber=session("displayNumber")
            end if
    else

...

I was certain my logic was rock solid. Turns out a simple syntax error was the source of my frustration.

Here is the answer to fixing the Object doesn't support this property or method: 'response.Cookies(...)'v vbscript runtime error

When you are using IF logic in vbscript, with ASP Cookies the "response" keyword is used to set Cookie values, and the "request" keyword is used to evaluate or retrieve values.

I had inadvertently used the "response" keyword to evaluate an IF statement. THAT is why it was producing the error, because the response.cookie object does not support a "value" evaluation. So, look at the IF line that casued the error (bold for emphasis)

if response.Cookies("ssnVisitor")("tracking_active")<>"yes" or session("tracking_active")="yes" then 'secondary logic

What it should read as, is ...

if request.Cookies("ssnVisitor")("tracking_active")<>"yes" or session("tracking_active")="yes" then 'secondary logic

Go back and look at my original code snippet again and see how many times I attempted to evaluate the value of a cookie by using the response keyword! What a simple mistake.

Conclusion

You cannot evaluate an IF statement in VBScript (ASP) using response.cookies() object, you will get a runtime error, and a warning that says "Object does not support this property of  method".

To evaluate the value of a Cookie using IF logic you must use the request.cookies() object.

I knew I couldn't be the only one.

Usually when the fix is so obvious, and so simple, it proves to be ridiculously hard to spot, and or fix. This is especially true if your editor, like Dreamweaver, color-keys your code. It will color it, and it will look correct. But it's not.

I hope this helps!

Be peaceful on your way,
Time_Spiraling

More by this Author


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working