Question

i have this code for cart items . data retrieve from website cookie,'MyKookie'

  <asp:ListView ID="List" runat="server" DataKeyNames="ID">
   >
<div class="margin">
    <table class="tbl">
        <tbody>
            <tr>
                <table>
                    <tbody>
                        <tr>
        <td class="one">
          <h4><%# Eval("ID")%></h4>
       </td>
       <td class="two">
       <h4><%# Eval("Name")%></h4>
         </td>
                            <td class="fone">9960</td>

                            <td>
                                <select class='drop'>
                                    <option value="1">1</option>
                                    <option value="2" selected="selected">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                </select>
                            </td>
                            <td class="fthree">20</td>
                            <td class="ffour">5000</td>
                        </tr>
                    </tbody>
                </table>
            </tr>
        </tbody>
    </table>

 </asp:ListView>

when user change quantity of one item , how to store changes in MyCookie?

Was it helpful?

Solution

Use jquery.cookie.js on client side. It's very easy:

$.cookie('cookie_name', 'cookie_value', {
expires: 5,
path: '/',
domain: 'subdomain.yoursite.ru',
secure: true

});

If u need it on server side:

var cookie = new HttpCookie("CookieName")
            {
                Value = JsonConvert.SerializeObject(model), // if value is object, else use simple string
                Expires = DateTime.Now.AddYears(1)
            };

            Response.Cookies.Add(cookie);

For geting cookie value:

var model = JsonConvert.DeserializeObject<ModelType>(Request.Cookies["CookieName"].Value); // or Request.Cookies["CookieName"].Value if simple string
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top