[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#22720: 25.0.91; url/eww: add function to delete all cookies
From: |
Michael Heerdegen |
Subject: |
bug#22720: 25.0.91; url/eww: add function to delete all cookies |
Date: |
Mon, 22 Feb 2016 13:52:21 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.91 (gnu/linux) |
Lars Ingebrigtsen <larsi@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.