Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

retrieving values in cookie

Options
  • 05-12-2003 10:31pm
    #1
    Registered Users Posts: 2,621 ✭✭✭


    Using asp.net and vb

    Right, I want to add the url of a page to a cookie, then I want to retrieve that info on another page. How can I do this?


Comments

  • Closed Accounts Posts: 8 WoodyWoodPecker


    its along the lines of ,

    Set cookie code

    HttpCookie cookUserInfo = new HttpCookie("UserInfo");
    cookUserInfo["txtsetCookie"] = Request.Url.AbsoluteUri;
    cookUserInfo.Expires = DateTime.Now.AddDays(1);
    Response.Cookies.Add(cookUserInfo);


    Get cookie code

    HttpCookie cookUserInfo = Request.Cookies["UserInfo"];
    txtgetCookie.Text = cookUserInfo["txtsetCookie"]; //Read value to text box on page


    Note
    this stores all the info. on the client but there are ways to store info on the server and just an ID on the client

    also what if the clients browser doesn't accept cookies then you need to fall back to storing the client ID in the URL for every call

    if you need any of these do a few googles or just in the help lookup the class HttpCookie and it will have loads of links


  • Registered Users Posts: 4,185 ✭✭✭deadl0ck


    You can do it client side with javaScript also


  • Moderators, Politics Moderators Posts: 39,564 Mod ✭✭✭✭Seth Brundle


    Originally posted by deadl0ck
    You can do it client side with javaScript also
    assuming client side javascript is enabled


Advertisement