Cookies again: Expiry Date

stephen barncard stephenREVOLUTION2 at barncard.com
Mon Sep 6 13:30:53 EDT 2010


I've also found that the 'normal' cookie listing in Safari security
preferences is difficult to work with - however *Develop:show web
inspector:storage pane*l shows cookies in a better way and refreshes easily.

For a while I thought my cookies weren't working - but it was because I was
setting the time and date to the current time - and that's the expiration
time and the entries wouldn't appear.

Here's my code for creating the correct format for the date:

<blockquote>

function returnCookieDate pSeconds,pGMTHours
-- returns a date compatible with cookie use:
--              Sun, 5-Sep-2010 15:25:12 GMT
--    requires setOffset, below
      if pGMTHours is empty then put "-0700" into pGMTHours
      if pSeconds is empty
      then
            put the seconds into pSeconds
      end if
      -- add or subtract zone offset (like -0700) from local to GMT in
seconds here
      put setOffset(pSeconds,pGMTHours) into pSeconds
      convert pSeconds to dateitems
      put pSeconds into tDateItems
      convert pSeconds to  internet date  --  like "Sun, 5 Sep 2010 15:25:12
-0700"
      put word 1 of pSeconds into tDay
      put (word 2 of pSeconds) & "-" & (word 3 of pSeconds) & "-" & (word 4
of pSeconds) into tDate
      put word 5 of pSeconds into tTime
      replace space with "-" in tTime
      return tDay && tDate && tTime && "GMT"
end returnCookieDate

function setOffset pSecs,pGMTHours
-- 20100905
-- figures offset for time zone relating to GMT
--     example   pGMTHours = "-0700"
--     pSecs is the time in seconds
      if character 1 of pGMTHours is "-"
      then
            delete character 1 of pGMTHours
            put "-" into pSign
      else
            put "" into pSign
      end if
      put character 1 to 2 of pGMTHours into t6oFS -- chop trailing zeros
      put (t6oFS * 3600) into tOffsetHourSeconds
      switch pSign
            case it is "-"
                  put (psecs - tOffsetHourSeconds ) into pSecs
                  break
            default
                  put (tOffsetHourSeconds  + pSecs ) into pSecs
      end switch
      return pSecs
end setOffset

</blockquote>

On 6 September 2010 09:45, Andre Garzia <andre at andregarzia.com> wrote:

> On Mon, Sep 6, 2010 at 1:36 PM, Gregory Lypny
> <gregory.lypny at videotron.ca> wrote:
> > Hi Stephen,
> >
> > Just to add to Andre's tip, I've found the setting and getting of cookies
> to be extremely finicky.  One thing that tripped me up for about four hours
> was the placement of <?rev in scripts.  It must appear in the very first
> line of any script involving cookies.  Leave a blank first line, and it is
> possible that everything in a script will work except for things having to
> do with cookies!
> >
>
> Gregory,
>
> That is not an actual bug but a design behaviour. RevServer engine
> will output things as soon as it can, meaning that the blank line will
> be sent as is back to apache server as soon as your script starts
> executing. HTTP Headers must be sent to apache before actual output is
> sent, so if you have a blank line on top of your file, that is treated
> by the engine as "hey you want to output a blank line, fine!" and thus
> all the subsequent put header calls will fail since apache will pick
> that blank line and start outputing everyting as content and not as
> headers.
>
> RevServer will start the flush output process if it finds anything
> that is not enclosed into a <?rev tag or if it finds the closing ?>
> tag.
>
> So if you start your code with a <?rev but closes it with a ?> and
> then the output will also begin. This is good to know because of
> includes, if you put ?> in your includes, the very act of including a
> file will start the output. So take those ?> out of the include files.
>
> Before anyone ask why this is so it is because PHP engine does it this
> way and we decided to copy them.
>
>
>
> > Regards,
> >
> > Gregory
> >
>
>
> --
> http://www.andregarzia.com All We Do Is Code.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



-- 



Stephen Barncard
San Francisco Ca. USA

more about sqb  <http://www.google.com/profiles/sbarncar>



More information about the use-livecode mailing list