Set Cookie by key, name and value - CSharp System.Web

CSharp examples for System.Web:Cookie

Description

Set Cookie by key, name and value

Demo Code


using System.Web;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*  w w  w  . j a  v a  2s.  com*/

public class Main{

        public static void SetCookie(string key,string name,string value)
        {
            var httpCookie = HttpContext.Current.Response.Cookies[key];
            if (httpCookie != null)
                httpCookie[name] = value;
            else
                Set(key,name,value);

        }
}

Related Tutorials