Question: I have two variables which needs to be created as a cookie. Can I give them just as without giving any expiration date but just as a key value pair,

```
 document.cookie = "<%= this.CookieDFKey %> = id";
 alert (document.cookie);
 document.cookie = "<%= this.CookieDateCompleteEnd %> = lastRunDate"; 
 window.location = '<%= ResolveUrl("~/GUI/DRNEW.aspx") %>';

```

When I gave the alert statement to check what value it is having it shows me 

[![enter image description here](https://i.stack.imgur.com/yc602.jpg)](https://i.stack.imgur.com/yc602.jpg)

I need to have both the values id and lastRunDate avaiable in the called page. Can I be just using `Request.Cookie[the name of cookie where the value store]`?

Answer: 
First cookies are key value pairs, you will get all `cookies` in `Request.Cookies`

If i'm not wrong in C#

```
 if (Request.Cookies["UserSettings"] != null)
    {
        string userSettings;
        if (Request.Cookies["UserSettings"]["Font"] != null)
        { userSettings = Request.Cookies["UserSettings"]["Font"]; }
    }

```

Read the below url to set multiple cookies in `document.cookie`

[Setting multiple cookies in Javascript](https://stackoverflow.com/questions/16842226/setting-multiple-cookies-in-javascript)
```
document.cookie = "id=<%= this.CookieDFKey %>";

```

document.cookie = "lastRunDate=<%= this.CookieDateCompleteEnd %> "; 

To retrieve cookie use the following code

```
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i = 0; i <ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length,c.length);
        }
    }
    return "";
}

```