vijay yaragall
vijay yaragall

Reputation: 111

How to reset the value of the cookie in javascript in mvc

I have to set the value of the LoginId textbox from the value in the cookie 'UserLoginId' then once I assign it to the textbox I have to set the value of the cookie to blank(or ""). I am not getting how to reset the value to " ".

<script type="text/javascript">    
    var jcookie = '@HttpContext.Current.Request.Cookies["UserLoginId"].Value';   
    $("#LogInId").val(jcookie);
// What to write here to set the value of "UserLoginId"=""?
</script>

Please help me with this..

Upvotes: 0

Views: 262

Answers (2)

Anton
Anton

Reputation: 1583

If you want to remove it, you should change expiration date:

document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';

Upvotes: 1

vijay yaragall
vijay yaragall

Reputation: 111

In the place of //What to writ here..

document.cookie = "userLoginId="+escape("");

Upvotes: 0

Related Questions