Page 1 of 1
The cookie of H. G. Wells (=^‥^=)
Posted: Tue Sep 20, 2016 5:16 pm
by Mariasole
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!
Could you kindly help me? I tried but I do not understand the syntax!
Thank you all!
Mariasole
(=^‥^=)
Re: The cookie of H. G. Wells (=^‥^=)
Posted: Tue Sep 20, 2016 8:17 pm
by dunbarx
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
Re: The cookie of H. G. Wells (=^‥^=)
Posted: Wed Sep 21, 2016 5:54 pm
by Mariasole
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.
That's all! This time there is no baroque reason!
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
(=^‥^=)
Re: The cookie of H. G. Wells (=^‥^=)
Posted: Wed Sep 21, 2016 6:19 pm
by dunbarx
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
Re: The cookie of H. G. Wells (=^‥^=)
Posted: Thu Sep 22, 2016 7:30 am
by [-hh]
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.
Re: The cookie of H. G. Wells (=^‥^=)
Posted: Thu Sep 22, 2016 1:51 pm
by dunbarx
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
Re: The cookie of H. G. Wells (=^‥^=)
Posted: Mon Sep 26, 2016 10:09 am
by Mariasole
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!
Mariasole
(=^‥^=)
Re: The cookie of H. G. Wells (=^‥^=)
Posted: Tue Oct 04, 2016 1:28 pm
by MaxV
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)