Results 1 to 3 of 3

Thread: {RESOLVED} Releasing cookies...

  1. #1

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Resolved {RESOLVED} Releasing cookies...

    Hi...

    I'm using C# (Vis .NET 2005) for Web Application.
    I've got a simple question to ask, coz I confuse on this thing.

    I've created a cookies at my Login form, named = "strUser".
    And I also add 1 button to Logout from system.
    I need to release that cookie when user press Logout button.

    I've tried to set the expires to 1 second, but nothing change.
    Code:
    logCookie.Expires = DateTime.Now.AddSeconds(1);
    I've also try to set the value to null, also not work.
    Code:
    logCookie.Value = null;
    And I've also tried to remove the cookie... this one ? also not work.
    Code:
    Request.Cookies.Remove("strUser");
    And finally, I've tried to clear the cookie. oh boy... also not work.
    Code:
    Request.Cookies.Clear();
    please someone help me on how to remove that cookies....
    thanks....

    Regards,
    ~ Wj ~
    SQL Server 2005 Developer
    Last edited by Wen Lie; May 15th, 2007 at 05:46 AM. Reason: resolved

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: Releasing cookies...

    Try this and you should be ok. You are expiring the cookie and sending it back to the client in the response.
    Code:
    Response.Cookies["strUser"].Expires = System.DateTime.Now.AddDays(-1);
    Last edited by Fishcake; May 15th, 2007 at 03:57 AM. Reason: Syntax

  3. #3

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Wink Re: Releasing cookies...

    hello fishcake...

    thanks... it works...
    ^_^
    Regards,
    [-w-]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width