Remember Cookie to Hours?

Now, I can get the cookie to expire after 1 day which is awesome. My next step would be to get it to expire after 10 hours so that it is guaranteed to have to be logged in once a day and have it expire during off work hours. So how do I set it to hours?

Hey Brad
You can try converting hours to days: https://www.calculateme.com/time/hours/to-days/10

Problem is the UI seems to only take days. I tried adding .45 days to see if it would give a ten hour cookie but it gave a 45 day cookie.

31%20AM

So what is it saving in the code?

“expires”: “.45”

We are going to check this.
Probably you can set your session expiration time meanwhile :slight_smile: and not use the cookie option at all.

Yep, I have time before I launch this dashboard. Thanks, if I could set this to hours that would be amazing. And I would owe you guys more beer than I already do. :wink:

1 Like

This now fixed in Wappler 2.2.2

So how do you do it in hours?

This isn’t answered @George. Still trying to figure out how to set it to hours and not days.

I have checked it, the cookie expires property originally was a HTTP-date timestamp but has been simplified to just days since it required the user to use separate formatters to get the correct timestamp.

I could make an update to support dates, then you could use an expression like {{ NOW.dateAdd('hours', 10) }}.

2 Likes

That would be awesome if there was a way to set it to hours. I’d appreciate that.

Is this still on the roadmap?

@patrick, any chance this can be done still?

I’m a bit too busy with other updates at the moment. I assume you use PHP, you can edit the file dmxConnectLib/lib/code/Response.php.

To have hours instead of days change line 74 to:

$expires = gmdate(DATE_COOKIE, strtotime($sign . abs($options->expires) . ' hours'));
2 Likes

Thanks Patrick! I will give that a try! Very much appreciated!

Worked like a charm! Love Wappler!

Any chance that someday the ability to set the expiry to hours will be implemented? It’s easy enough to change in the code but it gets overwritten in some Wappler updates and I have to change it again.

Not a deal breaker but would be nice to have.

It would still be nice if we could have a UI to set to hours (or even minutes). I change it in the code but it gets overwritten in Wappler updates.

Actually, now with the updater, even if I manually change it in the code, it wants to revert back every time I open Wappler.