This repository was archived by the owner on Sep 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Useful Functions to create , read and delete the cookies .
2+
3+ ( function ( $ ) {
4+ "use strict" ;
5+
6+ function createCookie ( name , value , days ) {
7+
8+ var expires ;
9+
10+ if ( days ) {
11+ var date = new Date ( ) ;
12+ date . setTime ( date . getTime ( ) + ( days * 24 * 60 * 60 * 1000 ) ) ;
13+ expires = "; expires=" + date . toGMTString ( ) ;
14+ } else {
15+ expires = "" ;
16+ }
17+ document . cookie = encodeURIComponent ( name ) + "=" + encodeURIComponent ( value ) + expires + "; path=/" ;
18+ }
19+
20+ // How to Create Cookies?
21+ createCookie ( 'el_data' , 'Prajakta' ) ;
22+
23+
24+ function readCookie ( name ) {
25+ var nameEQ = encodeURIComponent ( name ) + "=" ;
26+ var ca = document . cookie . split ( ';' ) ;
27+ for ( var i = 0 ; i < ca . length ; i ++ ) {
28+ var c = ca [ i ] ;
29+ while ( c . charAt ( 0 ) === ' ' )
30+ c = c . substring ( 1 , c . length ) ;
31+ if ( c . indexOf ( nameEQ ) === 0 )
32+ return decodeURIComponent ( c . substring ( nameEQ . length , c . length ) ) ;
33+ }
34+ return null ;
35+ }
36+
37+ // How to read cookies?
38+ var name = readCookie ( 'el_data' ) ;
39+
40+ function eraseCookie ( name ) {
41+ createCookie ( name , "" , - 1 ) ;
42+ }
43+
44+ // How to delete cookies?
45+ eraseCookie ( 'el_data' ) ;
46+
47+ } ) ( jQuery ) ;
You can’t perform that action at this time.
0 commit comments