2 * http://www.ocsigen.org
3 * Copyright (C) 2010 Vincent Balat
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, with linking exception;
8 * either version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 include Eliom_cookies_base
25 let cookie_table = ref Cookies.empty
28 let date = jsnew
Js.date_now
() in
29 Js.to_float
(date##getTime
())
31 let update_cookie_table cookieset
=
37 | OSet
(Some exp
, _
, _
) when exp
<= now ->
38 cookie_table := remove_cookie path name
!cookie_table
40 cookie_table := remove_cookie path name
!cookie_table
41 | OSet
(exp
, value, secure
) ->
44 path name
(exp
, value, secure
)
50 let get_cookies_to_send https path
=
53 (fun cpath t cookies_to_send
->
54 if List.is_prefix_skip_end_slash
55 (Url.remove_slash_at_beginning cpath
)
56 (Url.remove_slash_at_beginning path
)
57 then CookiesTable.fold
58 (fun name
(exp
, value, secure
) cookies_to_send
->
60 | Some exp
when exp
<= now ->
62 remove_cookie cpath name
!cookie_table;
65 if (not secure
) || https
66 then (name
,value)::cookies_to_send