Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

ASP Cookie Help


  • Please log in to reply

#1
Immortalarena

Immortalarena

    Member

  • Member
  • PipPipPip
  • 216 posts
I am starting to use cookies on a site driven by asp, but if a link on the site goes from http://example.com/ to http://www.example.com/ the cookie no longer works. Is there a way to instruct the cookie to work this way?

ASP Cookie:
Response.Cookies("user")("firstname")="John"


Thanks in advance!

-Matt :)
  • 0

Advertisements


#2
DragonMaster Jay

DragonMaster Jay

    Member

  • Banned
  • PipPipPip
  • 826 posts
Worth reading, IMO.
  • 0

#3
Immortalarena

Immortalarena

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 216 posts
Yes, that shows me how to make the cookie and set the expiration but doesn't have any information on having a cookie work on 2 hosts. www.example.com and example.com
My Cookies work, but I have to log in again if a page crosses between the two.
I can set the expiration by using:
Response.Cookies("user").Expires = Date() + 10

can I set the cookie like this
cookie("user").Host = "www.example.com"
cookie("user").Host = "example.com"

so that it works on both. I notice that this site uses ".geekstogo.com"
does that take care of this possibility?

Just trying to clarify a few points.

Edited by Immortalarena, 20 April 2009 - 11:23 PM.

  • 0

#4
DragonMaster Jay

DragonMaster Jay

    Member

  • Banned
  • PipPipPip
  • 826 posts
code the same cookie on both pages?
  • 0

#5
Immortalarena

Immortalarena

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 216 posts
Yes, the problem I'm having is there is a secure section of the site, and I want the cookie to work if they have www at the beginning of the site, and if they leave it off. Also if they log into the .com section of the site, they would get logged off when it was coded to go to the .net section. So I was wondering if there was an easy way to script the Cookie to work this way or if I had to have a scripted page that activated the cookie for each possibility. Thanks,
-Matt
  • 0

#6
Immortalarena

Immortalarena

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 216 posts
Sorry for Double Posting but I just found the answer to my question. I was looking for the Host element for the cookie, the actual term was Domain.

By Setting the
Response.Cookies("user").Domain = ".example.com"

I was able to avoid any confusion and it stays logged in no matter what part of the site I am on. Thanks a lot for the help. That .Domain was what I was looking for.

-Matt
  • 0

#7
DragonMaster Jay

DragonMaster Jay

    Member

  • Banned
  • PipPipPip
  • 826 posts
Very good. If you have any more questions, this thread will be open.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP