Results 1 to 4 of 4

Thread: Another cookie question

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Ohio
    Posts
    59
    I have a web page that connects to a database (SQL server) and loops through the data and generates a list of links to go to different areas of the site.

    When the user clicks the link I want to write a cookie so I know whick link they selected. Here's how the link is created.

    <a href="Profile.asp?Action=View&CId=<%=rs("tpClientId")%>&PId=<%=rs("tpProjectid")%>" name=tqproject language=vbscript onclick='buildname(<%Response.Write(chr(34) & rs("ptProjectDesc") & chr(34))%>)'><%=rs("ptProjectDesc")%></a>

    This calls the function just fine but, using response.cookies causes an error (see below). I suppose it's something to do with client/server side processing but I don't know.

    I don't want to use jscript to write the cookie (I'm using jscript in other areas just don't want to here, server seems much simpler).

    I've tried without the language= and other version but can't get it to work. Here's the latest buildname function.

    <script language=vbscript>
    sub buildname(sName)
    Response.Cookies("ProjName")=sName
    end sub
    </script>

    I'm not using the <form> tag. Will use it if required.
    I'm using ASP.

  2. #2
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224
    onclick='buildname(xxx)'
    <script language=vbscript>
    sub buildname(sName)
    Response.Cookies("ProjName")=sName
    end sub
    </script>

    Response object is Not Part of VBSCRIPT .. It is Part of ASP

    There fore It will not WORK !

    If you can't pronounce my name, call me GURU

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Ohio
    Posts
    59
    I knew it didn't work, but I'm looking for a solution to the task I've outlined.

    Can anyone point me in a direction to make this work(with whatever language, vbscript,jscript,asp).

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    From the server side, you would have to set the cookie before you send any HTML code (ie - Response.Write) as Cookies are sent as HTTP headers. So what you need to do is set the cookies on the page linked to, using the HTTP_REFERER Server Variable if needed to tell where the link came from.

    Josh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width