Cookies with JQuery
So in some of my latest projects i dont have full source access, so i need to look for cookies the main application is setting. To do this i am using jQuery to look into the cookies and give me the value. Once i know the value i can then write a new cookie that the main application will see and use.
Below is an idea of what i am doing to read the cookies from the main application.
1 2 3 4 | if($.cookie('Cookie_name')) { var MainAppCookie = $.cookie('Cookie_name'); $.cookie('NewCookie_' + MainAppCookie , 'Value'); } |
To use the $.cookie i am using a simple plugin for jQuery. This allows me to access the cookies quick and easy. Now if the application gives me a special cookie i can then delete my old ones by doing this…
1 2 3 | if($.cookie('Cookie_name') == 'Special Text') { $.cookie('MyCookie', null, {-1}); // This will delete the cookie } |


