

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to test if a JavaScript cookie has expired?
To test if a cookie has expired in JavaScript, add the following condition and check −
if( !($.cookie('myCookie') === null) ) { // Do something (cookie exists) } else { // Do something (cookie expired) }
You can also check it using a single line code −
checkCookie = $.cookie('myCookie') === null ? ( /*Condition TRUE...*/ ) : ( /*Condition FALSE...*/ );
- Related Questions & Answers
- How to set a cookie and get a cookie with JavaScript?
- How to read a cookie using JavaScript?
- Python – Test if tuple list has a single element
- Cookie Testing: Example Test Cases for Website
- How to test if a parameter is provided to a function in JavaScript?
- How to test if a URL string is absolute or relative - JavaScript?
- Check if a string has white space in JavaScript?
- How to check if a string has a certain piece of text in JavaScript?
- How to set JavaScript Cookie with no expiration date?
- How do you test if a value is equal to NaN in Javascript?
- Check if a PHP cookie exists and if not set its value
- How to test if a letter in a string is uppercase or lowercase using javascript?
- How to set cookie value with AJAX request in JavaScript?
- How to check if a date has passed in MySQL?
- How to test if an element contains class in JavaScript in HTML
Advertisements