Solved

Classic ASP Cookie Error

Posted on 2010-08-26
2
373 Views
Last Modified: 2012-08-14
At least some of my website visitors (possibly all) are getting the following error when my script is setting the expiry date of a cookie.

It happens the first time a user calls the page, but if they refresh it works fine.

Microsoft VBScript runtime
Type mismatch: 'Response.Cookies'
/locale.asp, line 24

23: Response.Cookies("locale") = Session("locale")
24: Response.Cookies("locale").Expires = DateAdd("m", 6, Now())

I can reproduce the problem and if I view the cookie information in IE developer tools immediately after the error, that cookie exists and the expiry date is correct, ie. 6 months from today.
0
Comment
Question by:knobbylowboy
2 Comments
 
LVL 11

Accepted Solution

by:
Rajesh Dalmia earned 250 total points
ID: 33529709
you are assigning Session("locale") into Response.Cookies("locale")...
seems like for the 1st time Session("locale") does not exist....
during refresh that session gets created and thus does not give any error
0
 

Author Closing Comment

by:knobbylowboy
ID: 33529813
I thought that the error was due to the expiry line but I see that under some circumstances I was passing a null value from a database into the session variable and then passing that value to the cookie so I guess the cookie didn't exist when I tried to set the expiry date.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now