[thelist] [ASP] cookie question

Ken Schaefer ken at adOpenStatic.com
Tue Feb 25 18:29:00 CST 2003

You say you want to set the cookie at the user's request. Can you set the
cookie using client-side javascript? (or you can do a postback to the
server, and set the cookie via ASP code).

When the user next comes back to the site, I don't see what you can't do:

strRedirect = Request.Cookies("Homepage")
strParams = Request.Cookies("OptionalParams")

Select Case strRedirect
    Case "FirstHomePage"
    Case "SecondHomePage"
        Response.Redirect("/someothersite/default.asp?" & strParams)
End Select

        <p>This is the default site homepage</p>


From: "Stephen Caudill" <SCaudill at municode.com>
Subject: [thelist] [ASP] cookie question

:   I am trying to create a cookie that when set, at the users request, will
change their default homepage on our site.  i.e. instead of hitting
index.asp, if the cookie is set then they receive /folder/file.asp as their
initial page.  The reason being that 90% of the traffic to our site goes
directly to a specific page (public access to info we host for clients) and
it would significantly reduce the amount of tech support our company has to
do trying to tell john q how to get to a page that is always one click
away... bleh.
:   I've run into a couple of hitches with this and its probably because I'm
a newbie to ASP.  First, the site uses one page for the layout and calls in
different content based on variables in the query string.  As you are likely
aware, the code for cookies must come before the <html> tag, and as there is
only one <html> tag in the whole site, I was a bit flummoxed at first, so I
came up with this code:
: home = int(request("home"))
: if home = 1 then
: response.Cookies("homepage") = "onlineCodes"
: response.Cookies("homepage") = "01/01/04"
: end if
: homepage=request.Cookies("homepage")
: if homepage = "onlineCodes" then
: response.Redirect("index.asp?nav=2&id=1")
: end if
: this is assuming that on the online codes page, there would be a button
which would post an additional parameter in the querystring which is home=1
if the user would like that to be their default page on our site.  The BIG
problem being, once this cookie is set, you get stuck in a response.redirect
loop.  I need to ensure that only the first time per session the user hits
the site, they are redirected there.  Any ideas on what is a good way to do
this?  I'm reading up on the session object right now, but would like to
know if I'm barking up the wrong tree.
: Thanks In Advance,
: Scuba Steve

More information about the thelist mailing list