Can I generate a time limited link for my website?

Hi,
I develop a website for guests staying at a particular guest house.
I want the customer to receive a link to the site on the day of arrival and for the site to be available for him until the day of departure.
Of course every time the link has to be different.
Is there anything that can be done using Wix code?
Maybe an idea for an option outside of Wix?

Thank you!

You can certainly do this with Wix.

You can have a database collection of your URLs, and one of the fields can be the expiration date. When the user comes to site, you can display the URL as long as the time and date is before the expiration. If it falls after, then the URL will no longer be available and you won’t display it.

is there any video explaining that

I’m interested in knowing more about this. Do you have a link you can share on this?

I’m in search of the same thing!

Do you already setted-up your project?

@russian-dima I’m not sure what you mean. I have a Wix site with a landing page that has a free offer. After someone opts in for the free offer, I would like to give them a link or code that expires in 24 hours.

@haircrafterjo

I just wanted to see how you setted-up your project, that means, which elements you are using, if you already have prepared a database, like mentioned/suggested by Yisrael?

If it comes to the following question:
Hi,
I develop a website for guests staying at a particular guest house.
I want the customer to receive a link to the site on the day of arrival and for the site to be available for him until the day of departure.
Of course every time the link has to be different.
Is there anything that can be done using Wix code?
Maybe an idea for an option outside of Wix?

Yes this should be feasible/possible. Also your wished function is possible to be done.

How i would proceed in your situation?

  1. First i would ask myself - → What do we have, what is my initial situation?
  2. Which elements am i using?
  3. What do i want to create?
  4. And how would be the flow of my project/function?

So let’s say we have a button on our page, which activates your mentioned → FREE-OFFER-FUNCTION. You click on the button another button appears, or you are redirected to another (hidden) page, there could be be different cases , how to manage this first step.

After sthis step has been done, your function should be activated, that means after theis first activating click → your 24-hours timer starts! HOW?

Like Yisrael mentioned, you will need a DATABASE for this, to be able to save the DATE and TIME of the proceeeded CLICK in your DB. Once you have saved the current date & time of the click a timer is running.

But how do the timer running? → It’s simple! Since you want to disable/disapear/hide the button after 24-hours again, you can set at the same time when you set the date & time - - → a SECOND date and time in a second row (called expirationDate/Time), but before you save the second date&time in the second row, you add to the expiration-date → (+24hours) and save it in your “expirationDate” column of your database.

Now you have two saved DATES → startDate & expirationDate.

Working with dates and times is not that easy and can create confusions very quick when working with them.

But if you always keep in mind that dates & times are calculated in → milliseconds
WHAT - - → MILLISECONDS ? :open_mouth: YES → MILLISECONDS , then you will have an easy game.

Perhaps reading this post here, also will help you…

So to make it short…

Set a → time-stamp of current date.
Add the milliseconds of 24-hours to the setted time-stamp…
…and you will get your expiration-date.

let timeStamp = new Date().getTime(); console.log(timeStamp)
let expirationDate = new Date(timeStamp+1000*60*60*24); console.log(expirationDate);
$w.onReady(async function() {
    let timeStamp = new Date().getTime(); console.log(timeStamp);
    let expirationDate = new Date(timeStamp+1000*60*60*24); console.log(expirationDate);
});

And the rest is pure - - → logic + perhaps in addition the following link…

BTW: These were your 24-hours → 10006060*24

Good luck!

I’ll create a tutorial video about this t topic very soon. Follow to know when it’s live.

@russian-dima I have not set up a database yet, but will be working on it next week and will refer back to your notes. Thank you!

@russian-dima so I set the timestamp which is the date and time as so:

 let timeStamp = new Date().getTime(),
     expirationDate = new Date(timeStamp+1000*60*60*24); 

Somewhere else in code:

 let expirationDate = getExpireTime();
 let timeStampNow = new Date().getTime(); 
 
 if (timeStampNow - expirationDate > 0) console.log("expire time");
 else console.log("time is not exipre");

And is this logic valid?

 let timeStamp = new Date().getTime(),
     expirationDate = new Date(timeStamp+1000*60*60*24); //24 hours in the future
 let timeStamp = new Date().getTime(),
     expirationDate = new Date(timeStamp+1000*60*60*1); //1 hours in the future
 let timeStamp = new Date().getTime(),
     expirationDate = new Date(timeStamp+1000*60*60*0.99); //59 Minutes in the future
 let timeStamp = new Date().getTime(),
     expirationDate = new Date(timeStamp+1000*60*60*0.7); //30 Mintuess in the future
 let timeStamp = new Date().getTime(),
     expirationDate = new Date(timeStamp+1000*60*60*0.5); //00 Mintuess in the future

@lv2lrn4lf
Not every of your examples is → CORRECT!
CORRECT!

expirationDate = new Date(timeStamp+1000*60*60*24); // 24-hours??? --> o.k.

CORRECT!

expirationDate = new Date(timeStamp+1000*60*60*1); // 1-hours??? --> o.k.

WRONG!

expirationDate = new Date(timeStamp+1000*60*60*0.7); // 30-minutes ??? ---> n.o.k.
expirationDate = new Date(timeStamp+1000*60*60*0.5); // 0-minutes ??? ---> n.o.k.

Please check all your examples, one more time.

1000 (milli-seconds) = 1 (second)
60 (seconds) = 1 (minute)
60 (minutes) = 1 (hour)

1000x60 ------------> 1 (minute)
1000x60x60 -------> 1 (hour)
1000x60x60x1 ----> 1 (hour)
1000x60x60x24 → 24 (hours) —> 1 (day)

Instead of doing this way…

expirationDate = new Date(timeStamp+1000*60*60*0.7); // 30-minutes ??? ---> n.o.k.
expirationDate = new Date(timeStamp+1000*60*60*0.5); // 0-minutes ??? ---> n.o.k.

Go this way…

expirationDate = new Date(timeStamp+1000*60*37); // 37-minutes ??? ---> o.k.
expirationDate = new Date(timeStamp+1000*60*30); // 30-minutes ??? ---> o.k.

Example: → use the → CONSOLE ← to check your RESULTS !

$w.onReady(function () {
    let timeStamp = new Date().getTime(); console.log("Current-Timestamp: ", timeStamp);
    let expirationDate1=new Date(timeStamp+1000*60*60*24);
    let expirationDate2=new Date(timeStamp+1000*60*60*1);
    let expirationDate3=new Date(timeStamp+1000*60*59);
    let expirationDate4=new Date(timeStamp+1000*60*30);
    let expirationDate5=new Date(timeStamp+1000*60*60*0.5);
    
    console.log("24-Hour: ", expirationDate1);
    console.log("1-Hour: ", expirationDate2);
    console.log("59-minutes: ", expirationDate3);
    console.log("30-minutes: ", expirationDate4);
    console.log("30-minutes: ", expirationDate5);
});

@russian-dima Thanks for the reply and comprehension lesson. I’ll remember this if things pick up and we are able to hire additional hands.

BUT this below is a valid way to use this? NOTE the

if (timeStampNow - expirationDate > 0) 

so I set the timestamp which is the date and time as so:

 let timeStamp = new Date().getTime(),
 expirationDate = new Date(timeStamp+1000*60*60*24); 

Somewhere else in code:

 let expirationDate = getExpireTime();
 let timeStampNow = new Date().getTime();
 
 if (timeStampNow - expirationDate > 0) console.log("expire time");
 else console.log("time is not exipre");

@lv2lrn4lf No problem. Always available and to be found in my profile.

That would be great! Thank you

@russian-dima So I reached out to someone through Fiverr who specializes in Velo and was told I can’t get set up the way I would like because I would need my course platform (New Zenler) to open up the API for us to do so. He said without access to that part of their platform, our hands are tied. Is that correct, or is there a way to create coupon code right in Wix that would expire in 24 hours? I’m also willing to pay someone if you can point me in the right direction.