Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. The problem during writing into an existing cookie, after re running my web application.......

The problem during writing into an existing cookie, after re running my web application.......

Scheduled Pinned Locked Moved ASP.NET
helpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vishnu Narayan Mishra
    wrote on last edited by
    #1

    The problem during writing into an existing cookie, after re running my web application hi to all forums members can any one tell me what is error in mine code, It create every time a new cookie, but i have to write into existing cookie. When i close my web application and re running my web application and, adding values into cookies it creates new cookies... why I m unable to understand.... following is my code... protected void btnAddCokkie_Click(object sender, EventArgs e) { CreateAndAddCookiesValue(); } private void CreateAndAddCookiesValue() { //Response.Cookies.Remove("ShowHistoryCookie"); if (Request.Browser.Cookies == true) { // Check the cookie Mycookie exist or not if (Request.Cookies["ShowHistoryCookie"] == null) { // If does Mycookie does not exist then create the cookie HttpCookie aShowHistoryCookie = new HttpCookie("ShowHistoryCookie"); Response.Cookies.Add(aShowHistoryCookie); // set expires to the datetime maxvalue Response.Cookies["ShowHistoryCookie"].Expires = DateTime.Now.AddMonths(1); //Response.Cookies["ShowHistoryCookie"].Expires = DateTime.MaxValue; //DateTime.Now.AddMonths(1) Response.Cookies["ShowHistoryCookie"]["URL"] += txtUrlLink.Text; } //Append UrlLink into existing cookie else { string strCookie = Request.Cookies["ShowHistoryCookie"]["URL"].ToString(); string strCook = strCookie; strCookie += "|" + txtUrlLink.Text; char[] splitter = { '|' }; string[] arInfo = new string[10]; arInfo = strCook.Split(splitter); int count = arInfo.Length; int intResult=-1; bool flag = false; //count to Restrict cookie to Store 10 UrlLink if (count <10) { //check to ensure that no duplicacy in UrlLink of cookies foreach (string str in arInfo) { intResult = str.CompareTo(txtUrlLink.Text); if (intResult == 0) { flag = true; break; } } i

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups