0

I wold like to use javascript to delete a cookie , the cookie name is "orinet" , I find the link Delete cookie by name? and change it to as below , but do not work , after run it , the cookie is still exist . What I would like to do is just remove the specific cookie ( or rename it , something like that ) , could advise what is wrong ? or could advise work around method to do it ? thanks

<script>
function del_cookie(name) {
    document.cookie = 'roundcube_sessauth' + 
     '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
     } 
     </script>

   <a href="javascript:del_cookie(orinet);">KILL</a>
Community
  • 1
  • 1
user2805388
  • 37
  • 1
  • 2
  • 6
  • possible duplicate of [Delete cookies via JavaScript](http://stackoverflow.com/questions/3918070/delete-cookies-via-javascript) – JBeagle Oct 09 '13 at 10:12

2 Answers2

0

You have syntax error in your call, orinet should be in quotes:

<a href="javascript:del_cookie('orinet');">KILL</a>

And also expires is not in proper format. Should be:

function del_cookie(name) {
    document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
} 
Alex
  • 1,657
  • 1
  • 12
  • 6
  • thanks replies , I am really can't use the above method to remove cookies , could advise if there is other method can do that ? thanks – user2805388 Oct 16 '13 at 01:34
0

your expires value is not proper format, change to:

function del_cookie(name) {
    document.cookie = 'roundcube_sessauth' + 
     '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
} 

and

<a href="javascript:del_cookie('orinet');">KILL</a>
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162