How do I set a cookie to expire after 1 minute or 30 seconds in Jquery?

Attila Naghi

How do i set my cookie to expire after 30 sec or 1 m ? this is my code :

$.cookie('username', username, { expires: 14 });  // expires after 14 days
Felix

For 1 minute, you can use:

var date = new Date();
date.setTime(date.getTime() + (60 * 1000));
$.cookie('username', username, { expires: date });  // expires after 1 minute

For 30 seconds, you can use:

var date = new Date();
date.setTime(date.getTime() + (30 * 1000));
$.cookie('username', username, { expires: date });  // expires after 30 second

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How do I expire a PHP session after 30 minutes?

From Dev

how to destroy cookie after 1 minute in cakephp?

From Java

How do I set/unset a cookie with jQuery?

From Dev

How do I terminate the game below after 30 seconds? I already have 1 timer, so I am not sure how to create a 2nd one and where to put it

From Dev

Set a cookie expire after 2 hours

From Dev

Set a cookie expire after 2 hours

From Dev

How can I get location after 30 seconds in android?

From Dev

setRepeating() of AlarmManager repeats after 1 minute no matter what the time is set (5 seconds in this case, API 18+)

From Dev

How can i trigger this jquery script to automatically run after a set amount of time (5 seconds maybe)?

From Dev

Display Jquery UI dialog after 30 seconds

From Dev

How to make a volley cache expire in exactly 1 minute

From Dev

jquery/css: I want to change the bgcolor of row only after hovering for 1 or 2 seconds. How to achieve this?

From Dev

How to set cookie Timeout less than 1 minute in Forms Authentication ASP.NET?

From Dev

How to properly expire cookie?

From Dev

Forcing a specific stored procedure to stop after 30 seconds: I do not want to reconfigure the timeout of the whole DB

From Java

How can I set the AWS API Gateway timeout higher than 30 seconds?

From Dev

C++ : How do I execute a function after several seconds?

From Dev

In MongoDB how do I convert seconds after epoch to Datetimes?

From Dev

How do I make the woocommerce message disappear after 5 seconds?

From Dev

How do I stop and skip a command after 3.5 seconds?

From Dev

How do I get the nc command to end after 2 seconds?

From Dev

In MongoDB how do I convert seconds after epoch to Datetimes?

From Dev

How do I remove a dynamically added element after 5 seconds?

From Dev

How do i make a token expire

From Dev

How do i make a token expire

From Dev

How do i pop message and set expire time to that message state stored in local storage?

From Dev

How do I cause an animation every 5 seconds using jQuery?

From Dev

how to refresh Repeater after 1 minute with javascript?

From Java

How do I set a cookie on HttpClient's HttpRequestMessage

Related Related

  1. 1

    How do I expire a PHP session after 30 minutes?

  2. 2

    how to destroy cookie after 1 minute in cakephp?

  3. 3

    How do I set/unset a cookie with jQuery?

  4. 4

    How do I terminate the game below after 30 seconds? I already have 1 timer, so I am not sure how to create a 2nd one and where to put it

  5. 5

    Set a cookie expire after 2 hours

  6. 6

    Set a cookie expire after 2 hours

  7. 7

    How can I get location after 30 seconds in android?

  8. 8

    setRepeating() of AlarmManager repeats after 1 minute no matter what the time is set (5 seconds in this case, API 18+)

  9. 9

    How can i trigger this jquery script to automatically run after a set amount of time (5 seconds maybe)?

  10. 10

    Display Jquery UI dialog after 30 seconds

  11. 11

    How to make a volley cache expire in exactly 1 minute

  12. 12

    jquery/css: I want to change the bgcolor of row only after hovering for 1 or 2 seconds. How to achieve this?

  13. 13

    How to set cookie Timeout less than 1 minute in Forms Authentication ASP.NET?

  14. 14

    How to properly expire cookie?

  15. 15

    Forcing a specific stored procedure to stop after 30 seconds: I do not want to reconfigure the timeout of the whole DB

  16. 16

    How can I set the AWS API Gateway timeout higher than 30 seconds?

  17. 17

    C++ : How do I execute a function after several seconds?

  18. 18

    In MongoDB how do I convert seconds after epoch to Datetimes?

  19. 19

    How do I make the woocommerce message disappear after 5 seconds?

  20. 20

    How do I stop and skip a command after 3.5 seconds?

  21. 21

    How do I get the nc command to end after 2 seconds?

  22. 22

    In MongoDB how do I convert seconds after epoch to Datetimes?

  23. 23

    How do I remove a dynamically added element after 5 seconds?

  24. 24

    How do i make a token expire

  25. 25

    How do i make a token expire

  26. 26

    How do i pop message and set expire time to that message state stored in local storage?

  27. 27

    How do I cause an animation every 5 seconds using jQuery?

  28. 28

    how to refresh Repeater after 1 minute with javascript?

  29. 29

    How do I set a cookie on HttpClient's HttpRequestMessage

HotTag

Archive