Solved

Classic ASP Cookie Error

Posted on 2010-08-26
2
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL and column defined as time 7 27
VB script help 23 36
StoredProcedure to JSON query faulty syntax 2 29
Validating number not work with decimal 4 29
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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