Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

ASP.NET remove cookie

What is the proper way to remove the cookie immediatley in the ELSE code below?
Dim RememberMe As Boolean
        If ck1.Checked = True Then
            RememberMe = True
        Else
            RememberMe = False
        End If
        If RememberMe = True Then
            'If they choose to remember there account
            Dim c As New System.Web.HttpCookie("royalUser", Trim(txtEmail.Text))
            c.Expires = Now.AddMonths(1)
            HttpContext.Current.Response.Cookies.Add(c)
 
            Dim p As New System.Web.HttpCookie("royalPass", Trim(txtPassword.Text))
            p.Expires = Now.AddMonths(1)
            HttpContext.Current.Response.Cookies.Add(p)
        Else
           
 
        End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of raterus
raterus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Munawar Hussain
Munawar Hussain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dim RememberMe As Boolean
        If ck1.Checked = True Then
            RememberMe = True
        Else
            RememberMe = False
        End If
        If RememberMe = True Then
            'If they choose to remember there account
            Dim c As New System.Web.HttpCookie("royalUser", Trim(txtEmail.Text))
            c.Expires = Now.AddMonths(1)
            HttpContext.Current.Response.Cookies.Add(c)
 
            Dim p As New System.Web.HttpCookie("royalPass", Trim(txtPassword.Text))
            p.Expires = Now.AddMonths(1)
            HttpContext.Current.Response.Cookies.Add(p)
        Else
           
  Dim cookieCols As New HttpCookieCollection
            cookieCols = Request.Cookies
            Request.Cookies.Remove("royalUser")
            Request.Cookies.Remove("royalPass")
        End If