The cookie of H. G. Wells (=^‥^=)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

The cookie of H. G. Wells (=^‥^=)

Post by Mariasole » Tue Sep 20, 2016 5:16 pm

Hello everyone!
I am continuing to study the fantastic Live Code Server!
I'm investigating the issue of cookies.
I know for example how to write a cookie that will expire in a year...

Code: Select all

put cookie "yearcookie" for "/" with "This cookie will stay on your system for a year" until (the seconds + 60 * 60 * 24 * 365)
But how do I write a cookie that has already expired for a year? Or in a precise date?

I tried this solution by putting a minus instead of a plus sign...

put cookie "yearcookie" for "/" with "This cookie will stay on your system for a year" until (the seconds - 60 * 60 * 24 * 365)

but it does not work! :oops:

Could you kindly help me? I tried but I do not understand the syntax!

Thank you all!
Mariasole
(=^‥^=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: The cookie of H. G. Wells (=^‥^=)

Post by dunbarx » Tue Sep 20, 2016 8:17 pm

Hi.
But how do I write a cookie that has already expired for a year? Or in a precise date?
Well, the precise date can be converted to the seconds, and you can find the difference from the current seconds, to give you a precise expiration instant, just as you did to set the expiring date in a year. I am sure you know how to do that.

But what does it mean when you want to put a cookie that has already expired, regardless of how long ago it actually did, in fact, expire?


Craig Newman

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: The cookie of H. G. Wells (=^‥^=)

Post by Mariasole » Wed Sep 21, 2016 5:54 pm

Hi Craig!
Thank you for your suggestion!

The fact is this: since a cookie can not be deleted, then I want that his date expires. 8)
That's all! This time there is no baroque reason! :lol:

But..I do not understand the syntax to use.

why ...(the seconds + 60 * 60 * 24 * 365) it works and ....(the seconds - 60 * 60 * 24 * 365) does not work?

And how can I write:
... until ("Thu, 01-Jan-1970 00:00:01 GMT")
I can only express it in seconds?

I did a lot of testing, but can not find an example of syntax.

Thank you for all your help!

Mariasole
(=^‥^=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: The cookie of H. G. Wells (=^‥^=)

Post by dunbarx » Wed Sep 21, 2016 6:19 pm

Hi.

I am no expert on cookies, but I would guess that the native command will not accept negative expiration dates. Someone else may chime in. Your requirement seems compelling, and a solution ought to be available, even if a kluge.

And if I understand the easy part of your question, yes, conversion to seconds is the way forward. If you want the cookie to expire on Valentines Day next year, (pseudo):

Code: Select all

on mouseUp
   put "2/14/2017" into temp
   convert temp to seconds
   subtract the seconds from temp
   "...until temp
end mouseUp
Craig

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: The cookie of H. G. Wells (=^‥^=)

Post by [-hh] » Thu Sep 22, 2016 7:30 am

Hi all.
Mariasole wrote: since a cookie can not be deleted, then I want that his date expires.
Why not use "... until the seconds + 1"?

p.s.
I'm an expert of cookies but as a side dish of an espresso only.
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: The cookie of H. G. Wells (=^‥^=)

Post by dunbarx » Thu Sep 22, 2016 1:51 pm

Herman is, as usual, thinking outside the cookie box.

Why indeed try to eat a cookie yesterday, when you can make it disappear as soon as you find it.

Craig

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: The cookie of H. G. Wells (=^‥^=)

Post by Mariasole » Mon Sep 26, 2016 10:09 am

Thank you Craig and Herman!
Now I try both solutions, but by instinct seems to me that they work!
Thank you for your kindness!
And if you want a recipe for cookies try these wine biscuits.

://ricette-utenti.cookaround.com/ciambelline-al-vino-1.html

They are very easy and yummy. Even men can do it successfully! :wink:

Mariasole
(=^‥^=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: The cookie of H. G. Wells (=^‥^=)

Post by MaxV » Tue Oct 04, 2016 1:28 pm

Mairasole,
you can't set a forever cookie. You can set only cookies with a long time. If the time expired, the browser delete them. Cookies are in the user browser/pc, not on your server.
Typically developers set a very long date (10 years is enough?):

Code: Select all

the seconds + (10 * 365 * 24 * 60 * 60)
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply