Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set expiration date on a cookie in cfscript

don't seem to be able to set the expiration date of a cookie within cfscript. any hints? it's coldfusion 9 btw.

like image 848
noobsaibot Avatar asked Jun 17 '10 08:06

noobsaibot


People also ask

How do you set the expiration date on cookies?

Set an expiration date for a cookie This can be done easily by adding expires=expirationDate in UTC separated by semicolon from the name=value, as seen in the following example: document. cookie = "username=Max Brown; expires=Wed, 05 Aug 2020 23:00:00 UTC"; document.

How do you set cookies to expire in 30 days?

Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If not set, the cookie will expire at the end of the session (when the browser closes). The path on the server in which the cookie will be available on.

Where is the cookie expiration date?

On the left side, under the Storage section, you'll see Cookies. Click on the arrow to display the website, then click on it. This will display all sorts of information about cookies, including their expiration date in the Expires/Max-Age column.

How do you read the expiration date on cookies?

Read the numbers after the letter as the date of the month and the year in which the item was produced. For example, if a code reads "D1519," that means April 15, 2019. Many products might have a closed code as well as an open-date code.


1 Answers

The <cfscript> equivalent to <cfcookie> offers only direct assignment of Cookie scope memory-only variables. You cannot use direct assignment to set persistent cookies that are stored on the user system. So you will have to write a wrapper function, if you want to set permanent cookies using script only CFML.

like image 122
Andreas Schuldhaus Avatar answered Sep 23 '22 10:09

Andreas Schuldhaus