Dynamic Cookie Names

Results 1 to 2 of 2

Thread: Dynamic Cookie Names

  1. #1
    Join Date
    Dec 1969

    Default Dynamic Cookie Names

    Is it possible to generate cookie names on the fly? I want to generate cookies based on a unique id that represents a record on a database and add a timestamp key. When the page is displayed I want to loop thru the recordset and if there is a cookie with the same id as the record but the timestamp on the database is later than the timestamp key on the cookie, I want to display a graphic next to the record indicating that the record has changed. Any ideas would be appreciated. <BR><BR><BR> <BR>

  2. #2
    Pedantic Bill Guest

    Default RE: Dynamic Cookie Names

    &nbsp;<BR>&#062; Is it possible to generate cookie names on the fly? <BR><BR>This is either too simple to believe or too complex for me<BR>to understand what you are asking.<BR><BR>From my viewpoint, cookie names are *ALWAYS* generated "on<BR>the fly." The ONLY way to create a cookie is to do something<BR>like:<BR><BR> Response.Cookies(cookieName) = cookieValue<BR><BR>And both the cookie name and the value are simply strings.<BR>Any kind of strings. Sure, most examples you see use<BR>a literal string for the cookieName, but VBScript is,<BR>after all, a general computer language. And there is no<BR>possible way the Response object can have any idea whether<BR>the VBS code you wrote used a literal string or some hairy<BR>expression or a function call or or or.<BR><BR>So simply:<BR> Response.Cookies("REC#" & RS("recID")) = CStr(RS("recDate"))<BR><BR>And, later,<BR> cookieDate = CDate( Response.Cookies("REC#" & RS(recID)))<BR> If DateDiff( cookieDate, RS("recDate" ) &#060; 0 Then ...<BR><BR>The "REC#" there is arbitrary...just making sure that the<BR>cookie name doesn&#039t happen to coincide with some other one.<BR><BR>But there are lots of other possibilities. Such as using<BR>multiple valued cookies.<BR><BR>Either I am completely missing the point of what you are<BR>asking or you need to read "Beginning Active Server Pages"<BR>(from WROX) or the equivalent.<BR><BR>If I completely missed the point, then please repost with<BR>more details and/or an example.<BR><BR>

Posting Permissions

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