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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

retrieving values in cookie

  • 05-12-2003 9: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,196 ✭✭✭deadl0ck


    You can do it client side with javaScript also


  • Moderators, Politics Moderators Posts: 41,230 Mod ✭✭✭✭Seth Brundle


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


Advertisement