- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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...*/ );
Advertisements