GNU bug report logs -
#22720
25.0.91; url/eww: add function to delete all cookies
Previous Next
Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>
Date: Wed, 17 Feb 2016 14:34:02 UTC
Severity: wishlist
Tags: fixed
Found in version 25.0.91
Fixed in version 26.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Oh, I see. I've now added this to the trunk:
> `url-cookie-delete-cookies'.
Thanks!
I guess it would also make sense to be able to keep cookies with
matching domain name. I tweaked your defun a bit:
#+begin_src emacs-lisp
(defun url-cookie-delete-cookies (&optional regexp keep)
"Delete all cookies from the cookie store where the domain matches REGEXP.
If REGEXP is nil, all cookies are deleted.
If KEEP is non-nil, delete all cookies where the domain does not
match REGEXP."
(dolist (variable '(url-cookie-secure-storage url-cookie-storage))
(if (not regexp)
(set variable nil)
(let ((cookies (symbol-value variable))
(pred (if keep
(lambda (cookie) (not (string-match-p regexp (car cookie))))
(lambda (cookie) (string-match-p regexp (car cookie))))))
(dolist (elem cookies)
(when (funcall pred elem)
(setq cookies (delq elem cookies))))
(set variable cookies))))
(setq url-cookies-changed-since-last-save t)
(url-cookie-write-file))
#+end_src
WDYT?
Regards,
Michael.
This bug report was last modified 8 years and 228 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.