Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

retrieving values in cookie

  • 05-12-2003 10:31PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 4,119 ✭✭✭deadl0ck


    You can do it client side with javaScript also


  • Moderators, Politics Moderators, Paid Member Posts: 44,054 Mod ✭✭✭✭Seth Brundle


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


Advertisement