Function: url-cookie-retrieve

url-cookie-retrieve is a byte-compiled function defined in url-cookie.el.gz.

Signature

(url-cookie-retrieve HOST &optional LOCALPART SECURE)

Documentation

Retrieve all cookies for a specified HOST and LOCALPART.

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-cookie.el.gz
(defun url-cookie-retrieve (host &optional localpart secure)
  "Retrieve all cookies for a specified HOST and LOCALPART."
  (let ((storage (if secure
		     (append url-cookie-secure-storage url-cookie-storage)
		   url-cookie-storage))
	(case-fold-search t)
        retval localpart-match)
    (dolist (cur storage)
      (and-let* ((cookies (cdr cur))
                 ;; Remove the dot from wildcard hosts before matching.
                 (found-host (string-remove-prefix "." (car cur))))
        (if (string-match
             (concat "^.*" (regexp-quote found-host) "$")
             host)
            ;; The hosts match - a possible hit!
            (dolist (cur cookies)
              (and (if (and (stringp
                             (setq localpart-match (url-cookie-localpart cur)))
                            (stringp localpart))
                       (string-match (concat "^" (regexp-quote localpart-match))
                                     localpart)
                     (equal localpart localpart-match))
                   (not (url-cookie-expired-p cur))
                   ;; Host-only cookies require exact match for host.
                   (or (not (string-empty-p (url-cookie-domain cur)))
                       (string= host found-host))
                   (setq retval (cons cur retval)))))))
    retval))