Solved

Classic ASP Cookie Error

Posted on 2010-08-26
2
375 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

14 Experts available now in Live!

Get 1:1 Help Now