I need to create a CDF with an expiry timestamp, that is, one that will show certain content before the expiry date and something else afterwards. I don’t want to get the timestamp from the user’s system because the users are my students and the sneaky rascals can, of course, reset their system dates and times to continue using the file. I had thought that maybe importing the most recent price of a stock, such as
What I can think of off the cuff. Use your own (University provided) site’s HTTP response header to send back the time. If user’s local time is with in a tolerance than you can trust their local time
Hey Hans,
Sorry for the late reply. Thanks for this. It’s clever. In tinkering with it, however, I’ve found that the initialization doesn’t pick up the current date and time. It works one time, but not when I relaunch the CDF. Could it be that CDFs are not “allowed” to import from URLs?
Greg
Now this worked each time I open the cdf file. It is a bit slow upon opening the first time. But it updates. The external URL is different from the above. But HTTPRequest seems to work in a CDF file. I am not using CDF Player. Other ideas are DockedCells, Using CloudDeploy or APIFunction to deploy an API call that returns a current timestamp. There are examples in the documentation.
Thanks for this. I’m afraid it kept giving me errors, so what I did instead was to wrap by URLRead call in Quiet and Check, allowing me to trap errors, one of which would be the user not being connected to the Internet.
Tested the docked cell cdf on Windows and Mac; upon opening it starts at 0 seconds and increments. If I change the OS(s) system clock, while the cdf file is opened, the panel stops updating. So, with a few more computations you can test when the TimeObject[] is static and do something. If the TimeObject[] based on the SessionTime[] reaches some criteria say two hours you can also do something.
I can’t readily think of a way to save the state such that upon reopening cdf file that the session starts at last time used.