python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
read cookies with key value pair in JavaScript jquery

read cookies with key value pair in JavaScript jquery

This is basically used to read the cookies data by using the key and value pair in MVC 5 jQuery. The code sample as give below.


var cookies = cookies || {};

cookies.read = new function (){

function setCokiesValue(key, value) {
    session[key] = value;
};

var session = [];

var getCookie = function readCookie() {
       match = document.cookie.match(new RegExp('MyCookieName' + '=([^;]+)'));
       if (match) {
           var array = match[1].split('&');
           for (var i = 0; i < array.length; i++) {
                name = array[i].split('=')[0];
                value = array[i].split('=')[1];
                session.push(setCokiesValue(name, value));
        }
    }
};

return {
       session :session ,
       getCookie :getCookie 
     }
}

ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions