@kbd{C-k} (@code{url-cookie-delete}) command.
@end defun
+@defun url-cookie-delete-cookies &optional regexp
+This function takes a regular expression as its parameters and deletes
+all cookies from that domain. If @var{regexp} is @code{nil}, delete
+all cookies.
+@end defun
+
@defopt url-cookie-file
The file in which cookies are stored, defaulting to @file{cookies} in
the directory specified by @code{url-configuration-directory}.
plist will contain a :peer element that has the output of
`gnutls-peer-status' (if Emacs is built with GnuTLS support).
++++
+*** The new function `url-cookie-delete-cookie' can be used to
+programmatically delete all cookies, or cookies from a specific
+domain.
+
** Tramp
+++
url-cookie-save-interval
#'url-cookie-write-file))))
+(defun url-cookie-delete-cookies (&optional regexp)
+ "Delete all cookies from the cookie store where the domain matches REGEXP.
+If REGEXP is nil, all cookies are deleted."
+ (dolist (variable '(url-cookie-secure-storage url-cookie-storage))
+ (let ((cookies (symbol-value variable)))
+ (dolist (elem cookies)
+ (when (or (null regexp)
+ (string-match regexp (car elem)))
+ (setq cookies (delq elem cookies))))
+ (set variable cookies)))
+ (setq url-cookies-changed-since-last-save t)
+ (url-cookie-write-file))
+
;;; Mode for listing and editing cookies.
(defun url-cookie-list ()