Re: Expire Cookie in 8 Hours

This WebDNA talk-list message is from

2004


It keeps the original formatting.
numero = 58205
interpreted = N
texte = Clint Davis wrote: > I want to set a cookie that expires in 8 hours. If the cookie is set after > 4pm GMT, it should expire the next morning, so the date needs to change. > Does anyone have a code snippet to handle this? This half of the MIMEHeaders.inc code does the calculations. NOTE: the [date format=%Z] test may be wrong if you are not running Windows. > [!] ------- GMTdate.inc ------- > Takes optional parameter offset in minutes and returns current date/time in GMT long format > Replace the {5:00:00} with your non-DST offset from GMT > [/!][math time&show=f]GMT={[date %X]}+{5:00:00}[showif [date format=%Z]^Daylight]-{1:00:00}[/showif][/math][!] > [/!][math time&show=f]NOW={[date %X]}[/math][!] > [/!][if "[offset]"="[raw][offset][/raw]"][!] > [/!][then][!] > [/!][math show=f]offsettime=0[/math][/then][!] > [/!][else][!] > [/!][math show=f]offsettime=[offset]*60[/math][/else][!] > [/!][/if][!] > --- Create the GMTexpires variable > [/!][math time&show=f]GMTexpires=[GMT]+[offsettime][/math][!] > --- Create the MIMEexpires string > [/!][text show=t]MIMEexpires=[!] > [/!][if ([GMT]>[NOW]) and ([GMTexpires]>[GMT]) and ([GMTexpires]<86400)][!] ---- all in the same day ---- > [/!][then][!] > [/!][date format=%a, %d %b %Y][!] > [/!][/then][!] ---- at least one day later ---- > [/!][else][!] > [/!][format days_to_date %a, %d %b %Y][math]{[date]}+{00/[!] > [/!][showif [GMTexpires]>86400][math]floor([GMTexpires]/86400)[/math][/showif][!] > [/!][showif [GMTexpires]<86401]01[/showif][!] > [/!]/0000}[/math][/format][!] > [/!][/else][!] > [/!][/if][!] > [/!] [Format Seconds_To_Time][GMTexpires][/Format][!] > [/!] GMT[/text] HTH John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Expire Cookie in 8 Hours ( John Peacock 2004)
  2. Re: Expire Cookie in 8 Hours ( Clint Davis 2004)
  3. Re: Expire Cookie in 8 Hours ( John Peacock 2004)
  4. Expire Cookie in 8 Hours ( Clint Davis 2004)
Clint Davis wrote: > I want to set a cookie that expires in 8 hours. If the cookie is set after > 4pm GMT, it should expire the next morning, so the date needs to change. > Does anyone have a code snippet to handle this? This half of the MIMEHeaders.inc code does the calculations. NOTE: the [date format=%Z] test may be wrong if you are not running Windows. > [!] ------- GMTdate.inc ------- > Takes optional parameter offset in minutes and returns current date/time in GMT long format > Replace the {5:00:00} with your non-DST offset from GMT > [/!][math time&show=f]GMT={[date %X]}+{5:00:00}[showif [date format=%Z]^Daylight]-{1:00:00}[/showif][/math][!] > [/!][math time&show=f]NOW={[date %X]}[/math][!] > [/!][if "[offset]"="[raw][offset][/raw]"][!] > [/!][then][!] > [/!][math show=f]offsettime=0[/math][/then][!] > [/!][else][!] > [/!][math show=f]offsettime=[offset]*60[/math][/else][!] > [/!][/if][!] > --- Create the GMTexpires variable > [/!][math time&show=f]GMTexpires=[GMT]+[offsettime][/math][!] > --- Create the MIMEexpires string > [/!][text show=t]MIMEexpires=[!] > [/!][if ([GMT]>[NOW]) and ([GMTexpires]>[GMT]) and ([GMTexpires]<86400)][!] ---- all in the same day ---- > [/!][then][!] > [/!][date format=%a, %d %b %Y][!] > [/!][/then][!] ---- at least one day later ---- > [/!][else][!] > [/!][format days_to_date %a, %d %b %Y][math]{[date]}+{00/[!] > [/!][showif [GMTexpires]>86400][math]floor([GMTexpires]/86400)[/math][/showif][!] > [/!][showif [GMTexpires]<86401]01[/showif][!] > [/!]/0000}[/math][/format][!] > [/!][/else][!] > [/!][/if][!] > [/!] [Format Seconds_To_Time][GMTexpires][/Format][!] > [/!] GMT[/text] HTH John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ John Peacock

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Associative lookup style? + bit more (1997) re: Large databases in WebCat (1997) [WebDNA] Webdna error on plain html site (2013) [blank] (2005) instant cookies? (1999) WC2.0 Memory Requirements (1997) How To Install (2003) WebCat2b13 Mac plugin - [sendmail] and checkboxes (1997) PCS Frames (1997) 2.0 Info (1997) WebCat 3? (2000) [ot] New List. Was: Webcat no longer supported? (2006) Images (2000) Multiple Pulldowns (1997) RE: Error: template (1997) A dynamic database. (1997) Order not created error (1997) all records returned. (1997) Moment of Thanks (1997) 2 easy questions re: [showif] and [sendmail] (1997)