Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Problem with cookies
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem with cookies

 Post Reply Post Reply
Author
photoshop_god View Drop Down
Newbie
Newbie
Avatar

Joined: 21 January 2004
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote photoshop_god Quote  Post ReplyReply Direct Link To This Post Topic: Problem with cookies
    Posted: 26 December 2004 at 7:28pm
Hi all,
 
I have been looking and playing around with this code trying to figure out why I get this error.
 
Here is the code that is causing the problem:
 
'Set the destination URL
''********************************************************** **************
DestURL = rs("DestURL")
 
Response.Cookies(strCookieName)("GPAUsername") = rs("GPAUsername")
Response.Cookies(strCookieName)("FirstName") = rs("FirstName")
Response.Cookies(strCookieName)("LastName") = rs("LastName")
Response.Cookies(strCookieName)("Email") = rs("Email")
Response.Cookies(strCookieName)("Account1") = rs("Account1")
Response.Cookies(strCookieName)("Account2") = rs("Account2")
Response.Cookies(strCookieName)("Account3") = rs("Account3")
Response.Cookies(strCookieName)("UserGood") = "Yes"
Response.Cookies(strCookieName)("Admin") = rs("Admin")
Response.Cookies(strCookieName)("Location") = rs("Location")
Response.Cookies(strCookieName)("Valid") = rs("Valid")
Response.Cookies(strCookieName)("Suspended") = rs("Suspended")
Response.Cookies(strCookieName).Domain = "www.gpagallery.com"
Response.Cookies(strCookieName).Expires = strExpireDate
Session("UserMessages") = rs("UserMessages")
 
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Redirect DestURL
Else

'Set the destination URL
''********************************************************** **************
DestURL = rs("DestURL")
 
Session("GPAUsername") = rs("GPAUsername")
Session("FirstName") = rs("FirstName")
Session("LastName") = rs("LastName")
Session("Email") = rs("Email")
Session("Account1") = rs("Account1")
Session("Account2") = rs("Account2")
Session("Account3") = rs("Account3")
Session("UserGood") = "Yes"
Session("Admin") = rs("Admin")
Session("Location") = rs("Location")
Session("UserMessages") = rs("UserMessages")
Session("Valid") = rs("Valid")
Session("AutoLoginReminder") = "Yes"
Session("Suspended") = rs("Suspended")
 
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Redirect DestURL
 
The code works fine when you use the session variables but when you use the cookies I get this error
 
Microsoft VBScript runtime error '800a000d'

Type mismatch: '[object]'

/login_checkuser.asp, line 163

line 163 is Response.Cookies(strCookieName)("Account1") = rs("Account1")
The Account1 field is setup just like the first name field.(a text field)  I'm using an access 2000 database running on a win 2000 server.
This error happens when I leave this field blank.  When I populate it I get the error on the Account2 line.  I tried leaving another field blank like location or first name and I have no problems.  I'm scratching my head trying to figure out what is going on.  Any help would be appreciated. 
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 26 December 2004 at 11:13pm
Cookies tend to be sensitive to null values. More than likely the Account fields in your db default to null when empty. Try something like
Response.Cookies(strCookieName)("Account1") = "" & rs("Account1")
which has the effect of concatenating an empty string with the db field.
 
Another way to do it is
If IsNull(rs("Account1")) then
    Response.Cookies(strCookieName)("Account1") = ""
else
    Response.Cookies(strCookieName)("Account1") = rs("Account1")
End If
 
A null string is not the same as an empty string. A string has hidden end-of-string characters that cookies like. Some browsers and some server settings regard a null in a cookie as a cookie block.
 
EDIT: To add color highlight


Edited by dpyers - 26 December 2004 at 11:14pm

Lead me not into temptation... I know the short cut, follow me.
Back to Top
photoshop_god View Drop Down
Newbie
Newbie
Avatar

Joined: 21 January 2004
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote photoshop_god Quote  Post ReplyReply Direct Link To This Post Posted: 27 December 2004 at 9:06am
Thanks dpyers
 
I guess I didn't realize that about cookies.  I'll give this a try.  I'm sure this is what the problem is.  Thanks again.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.