2 * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 #include "chxj_cookie.h"
21 #include "chxj_url_encode.h"
22 #include "chxj_apply_convrule.h"
23 #include "chxj_str_util.h"
25 #include "ap_release.h"
31 #include "apr_base64.h"
36 #if defined(USE_MYSQL_COOKIE)
37 # include "chxj_mysql.h"
39 #if defined(USE_MEMCACHE_COOKIE)
40 # include "chxj_memcache.h"
45 static char* s_get_hostname_from_url(request_rec* r, char* value);
46 static char* s_cut_until_end_hostname(request_rec*, char* value);
47 static int valid_domain(request_rec *r, const char *value);
48 static int valid_path(request_rec *r, const char *value);
49 static int valid_expires(request_rec *r, const char *value);
50 static int valid_secure(request_rec *r, const char *value);
51 static int check_valid_cookie_attribute(request_rec *r, const char *pair);
55 alloc_cookie_id(request_rec *r)
59 unsigned char *md5_value;
64 uuid_string = apr_palloc(r->pool, APR_UUID_FORMATTED_LENGTH + 1);
65 memset(uuid_string, 0, APR_UUID_FORMATTED_LENGTH + 1);
66 apr_uuid_format(uuid_string, &uuid);;
68 md5_value = (unsigned char*)apr_palloc(r->pool, APR_MD5_DIGESTSIZE + 1);
69 memset(md5_value, 0, APR_MD5_DIGESTSIZE + 1);
71 retval = apr_md5(md5_value,
72 (const char*)uuid_string,
73 APR_UUID_FORMATTED_LENGTH);
74 if (retval != APR_SUCCESS) {
75 ERR(r, "md5 failed.");
79 cookie_id = apr_palloc(r->pool, apr_base64_encode_len(APR_MD5_DIGESTSIZE)+1);
80 memset(cookie_id, 0, APR_MD5_DIGESTSIZE+1);
81 apr_base64_encode(cookie_id, (char*)md5_value, APR_MD5_DIGESTSIZE);
83 DBG(r, "cookie_id=[%s]", cookie_id);
85 cookie_id = chxj_url_encode(r,cookie_id);
87 DBG(r, "cookie_id=[%s]", cookie_id);
96 chxj_save_cookie(request_rec* r)
99 apr_array_header_t* headers;
100 apr_table_entry_t* hentryp;
103 mod_chxj_config *dconf;
104 chxjconvrule_entry *entryp;
105 apr_table_t* new_cookie_table;
108 cookie_t* old_cookie;
110 apr_uri_t parsed_uri;
114 DBG(r, "start chxj_save_cookie()");
116 cookie = (cookie_t*)apr_palloc(r->pool, sizeof(cookie_t));
117 cookie->cookie_id = NULL;
122 dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
123 entryp = chxj_apply_convrule(r, dconf->convrules);
125 DBG(r, "end chxj_save_cookie() no pattern");
128 if (! (entryp->action & CONVRULE_COOKIE_ON_BIT)) {
129 DBG(r, "end chxj_save_cookie() CookieOff");
135 headers = (apr_array_header_t*)apr_table_elts(r->headers_out);
136 hentryp = (apr_table_entry_t*)headers->elts;
139 new_cookie_table = apr_table_make(r->pool, 0);
141 for (ii=0; ii<headers->nelts; ii++) {
142 if (strcasecmp(hentryp[ii].key, "Set-Cookie") == 0) {
143 DBG(r, "=====================================");
144 DBG(r, "cookie=[%s:%s]", hentryp[ii].key, hentryp[ii].val);
151 buff = apr_pstrdup(r->pool, hentryp[ii].val);
152 val = strchr(buff, '=');
156 apr_table_add(new_cookie_table, key, val);
157 if (strcasecmp(REFERER_COOKIE_KEY, key) == 0) has_refer++;
162 DBG(r, "=====================================");
165 apr_table_unset(r->headers_out, "Set-Cookie");
168 apr_uri_parse(r->pool,r->uri, &parsed_uri);
169 refer_string = apr_psprintf(r->pool,
171 chxj_run_http_scheme(r),
173 apr_uri_unparse(r->pool,
175 APR_URI_UNP_OMITSITEPART));
176 if (r->args && strlen(r->args)) {
177 refer_string = apr_pstrcat(r->pool, refer_string, "?", r->args, NULL);
179 apr_table_setn(new_cookie_table, REFERER_COOKIE_KEY, refer_string);
180 DBG(r, "ADD REFER[%s]", refer_string);
186 * check input parameters
188 old_cookie_id = (char*)apr_table_get(r->headers_in, "CHXJ_COOKIE_ID");
190 old_cookie = chxj_load_cookie(r, old_cookie_id);
191 if (old_cookie && old_cookie->cookie_headers) {
192 hentryp = (apr_table_entry_t*)old_cookie->cookie_headers->elts;
193 for (ii=0; ii<old_cookie->cookie_headers->nelts; ii++) {
194 if (hentryp && apr_table_get(new_cookie_table, hentryp[ii].key) == NULL) {
195 apr_table_add(new_cookie_table, hentryp[ii].key, hentryp[ii].val);
199 chxj_delete_cookie(r, old_cookie_id);
200 chxj_delete_cookie_expire(r, old_cookie_id);
206 DBG(r, "end chxj_save_cookie()");
213 cookie->cookie_headers = (apr_array_header_t*)apr_table_elts(new_cookie_table);
214 store_string = apr_palloc(r->pool, 1);
216 hentryp = (apr_table_entry_t*)cookie->cookie_headers->elts;
218 for (ii=0; ii<cookie->cookie_headers->nelts; ii++) {
219 if (ii) store_string = apr_pstrcat(r->pool,
224 store_string = apr_pstrcat(r->pool,
232 if (old_cookie_id && IS_COOKIE_LAZY(dconf)) {
233 DBG(r, "LAZY COOKIE save");
234 cookie->cookie_id = apr_pstrdup(r->pool, old_cookie_id);
237 DBG(r, "NO LAZY COOKIE save");
238 cookie->cookie_id = alloc_cookie_id(r);
241 DBG(r, "TYPE:[%d]", dconf->cookie_store_type);
244 #if defined(USE_MYSQL_COOKIE)
245 if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
246 if (! chxj_save_cookie_mysql(r, dconf, cookie->cookie_id, store_string)) {
247 ERR(r, "faild: chxj_save_cookie_mysql() cookie_id:[%s]", cookie->cookie_id);
253 #if defined(USE_MEMCACHE_COOKIE)
254 if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
255 if (! chxj_save_cookie_memcache(r, dconf, cookie->cookie_id, store_string)) {
256 ERR(r, "failed: chxj_save_cookie_memcache() cookie_id:[%s]", cookie->cookie_id);
262 if (IS_COOKIE_STORE_DBM(dconf->cookie_store_type) || ! done_proc) {
263 if (! chxj_save_cookie_dbm(r, dconf, cookie->cookie_id, store_string)) {
264 ERR(r, "failed: chxj_save_cookie_dbm() cookie_id:[%s]", cookie->cookie_id);
271 chxj_save_cookie_expire(r, cookie);
276 DBG(r, "end chxj_save_cookie()");
284 chxj_update_cookie(request_rec* r, cookie_t* old_cookie)
287 apr_array_header_t* headers;
288 apr_table_entry_t* hentryp;
290 mod_chxj_config* dconf;
291 chxjconvrule_entry* entryp;
295 DBG(r, "start chxj_update_cookie()");
296 if (!old_cookie || ! old_cookie->cookie_headers || ! old_cookie->cookie_id) {
297 DBG(r, "end chxj_update_cookie() (old_cookie is null)");
301 cookie = (cookie_t*)apr_palloc(r->pool, sizeof(cookie_t));
302 cookie->cookie_id = NULL;
305 dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
306 entryp = chxj_apply_convrule(r, dconf->convrules);
308 DBG(r, "end chxj_update_cookie() no pattern");
311 if (! (entryp->action & CONVRULE_COOKIE_ON_BIT)) {
312 DBG(r, "end chxj_update_cookie() CookieOff");
317 headers = (apr_array_header_t*)apr_table_elts(r->headers_out);
318 hentryp = (apr_table_entry_t*)headers->elts;
321 chxj_delete_cookie(r, old_cookie->cookie_id);
322 chxj_delete_cookie_expire(r, old_cookie->cookie_id);
324 if (IS_COOKIE_LAZY(dconf)) {
326 cookie->cookie_id = apr_pstrdup(r->pool, old_cookie->cookie_id);
329 DBG(r, "NO LAZY MODE");
330 cookie->cookie_id = alloc_cookie_id(r);
333 cookie->cookie_headers = old_cookie->cookie_headers;
334 store_string = apr_palloc(r->pool, 1);
336 hentryp = (apr_table_entry_t*)cookie->cookie_headers->elts;
338 for (ii=0; ii<cookie->cookie_headers->nelts; ii++) {
339 if (ii) store_string = apr_pstrcat(r->pool,
344 DBG(r, "OLD COOKIE VALUE=[%s][%s]", hentryp[ii].key, hentryp[ii].val);
345 store_string = apr_pstrcat(r->pool,
355 #if defined(USE_MYSQL_COOKIE)
356 if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
357 if (!chxj_update_cookie_mysql(r, dconf, cookie->cookie_id, store_string)) {
358 ERR(r, "failed: chxj_update_cookie_mysql() cookie_id:[%s]", cookie->cookie_id);
365 #if defined(USE_MEMCACHE_COOKIE)
366 if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
367 if (! chxj_update_cookie_memcache(r, dconf, cookie->cookie_id, store_string)) {
368 ERR(r, "failed: chxj_update_cookie_memcache() cookie_id:[%s]", cookie->cookie_id);
374 if (!done_proc || IS_COOKIE_STORE_DBM(dconf->cookie_store_type)) {
375 if (! chxj_update_cookie_dbm(r, dconf, cookie->cookie_id, store_string)) {
376 ERR(r, "failed: chxj_update_cookie_dbm() cookie_id:[%s]", cookie->cookie_id);
382 chxj_save_cookie_expire(r, cookie);
384 apr_table_setn(r->headers_in, "CHXJ_COOKIE_ID", cookie->cookie_id);
388 DBG(r, "end chxj_update_cookie()");
395 * @return loaded data.
398 chxj_load_cookie(request_rec* r, char* cookie_id)
400 mod_chxj_config *dconf;
401 chxjconvrule_entry *entryp;
403 apr_table_t *load_cookie_table;
404 char *load_string = NULL;
411 DBG(r, "========================================================");
412 DBG(r, "========================================================");
413 DBG(r, "========================================================");
414 DBG(r, "========================================================");
415 DBG(r, "start chxj_load_cookie() cookie_id=[%s]", cookie_id);
416 chxj_cookie_expire_gc(r);
418 cookie = (cookie_t*)apr_palloc(r->pool, sizeof(cookie_t));
419 cookie->cookie_headers = NULL;
420 cookie->cookie_id = apr_pstrdup(r->pool, cookie_id);
422 dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
423 entryp = chxj_apply_convrule(r, dconf->convrules);
425 DBG(r, "end chxj_load_cookie() no pattern");
428 if (! (entryp->action & CONVRULE_COOKIE_ON_BIT)) {
429 DBG(r, "end chxj_load_cookie() CookieOff");
432 load_cookie_table = apr_table_make(r->pool, 0);
436 #if defined(USE_MYSQL_COOKIE)
437 if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
438 if (! (load_string = chxj_load_cookie_mysql(r, dconf, cookie->cookie_id))) {
439 ERR(r, "failed: chxj_load_cookie_mysql() cookie_id:[%s]", cookie_id);
445 #if defined(USE_MEMCACHE_COOKIE)
446 if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
447 if (! (load_string = chxj_load_cookie_memcache(r, dconf, cookie->cookie_id))) {
448 ERR(r, "failed: chxj_load_cookie_memcache() cookie_id:[%s]", cookie_id);
454 if (!done_proc || IS_COOKIE_STORE_DBM(dconf->cookie_store_type)) {
455 if (! (load_string = chxj_load_cookie_dbm(r, dconf, cookie->cookie_id))) {
456 ERR(r, "failed: chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
463 DBG(r, "load_string=[%s]", load_string);
464 header_cookie = apr_palloc(r->pool, 1);
465 header_cookie[0] = 0;
468 pair = apr_strtok(load_string, "\n", &pstat);
472 DBG(r, "Cookie:[%s]", pair);
475 tmp_pair = apr_pstrdup(r->pool, pair);
476 val = strchr(tmp_pair, '=');
480 apr_table_add(load_cookie_table, key, val);
481 DBG(r, "ADD key:[%s] val:[%s]", key, val);
483 tmp_pair = apr_pstrdup(r->pool, pair);
484 tmp_sem = strchr(tmp_pair, ';');
488 if (check_valid_cookie_attribute(r, pair)) {
489 if (strlen(header_cookie))
490 header_cookie = apr_pstrcat(r->pool, header_cookie, ";", NULL);
492 header_cookie = apr_pstrcat(r->pool, header_cookie, tmp_pair, NULL);
495 if (strlen(header_cookie)) {
496 DBG(r, "ADD COOKIE to REQUEST HEADER:[%s]", header_cookie);
497 apr_table_add(r->headers_in, "Cookie", header_cookie);
500 cookie->cookie_headers = (apr_array_header_t*)apr_table_elts(load_cookie_table);
502 if (apr_table_get(r->headers_in, "referer") == NULL) {
503 apr_table_setn(r->headers_in,
505 apr_table_get(load_cookie_table, REFERER_COOKIE_KEY));
509 * save cookie_id to request header.
511 apr_table_setn(r->headers_in, "CHXJ_COOKIE_ID", cookie->cookie_id);
514 DBG(r, "end chxj_load_cookie()");
515 DBG(r, "========================================================");
516 DBG(r, "========================================================");
517 DBG(r, "========================================================");
518 DBG(r, "========================================================");
525 DBG(r, "end chxj_load_cookie()");
526 DBG(r, "========================================================");
527 DBG(r, "========================================================");
528 DBG(r, "========================================================");
529 DBG(r, "========================================================");
534 check_valid_cookie_attribute(request_rec *r, const char *value)
545 DBG(r, "start check_valid_cookie_attribute() value:[%s]", value);
547 domain_pair = path_pair = expire_pair = secure_pair = NULL;
548 p = apr_pstrdup(r->pool, value);
550 /* pass first pair */
551 first_pair = apr_strtok(p, ";", &pstat);
554 pair = apr_strtok(NULL, ";", &pstat);
556 pair = qs_trim_string(r->pool, pair);
557 if (STRNCASEEQ('d','D',"domain", pair, sizeof("domain")-1)) {
558 domain_pair = apr_pstrdup(r->pool, pair);
560 else if (STRNCASEEQ('p','P',"path", pair, sizeof("path")-1)) {
561 path_pair = apr_pstrdup(r->pool, pair);
563 else if (STRNCASEEQ('e','E',"expires", pair, sizeof("expires")-1)) {
564 expire_pair = apr_pstrdup(r->pool, pair);
566 else if (STRNCASEEQ('s','S',"secure", pair, sizeof("secure")-1)) {
567 secure_pair = apr_pstrdup(r->pool, pair);
572 if (!valid_domain(r, domain_pair)) {
573 DBG(r, "invalid domain. domain_pair:[%s]", domain_pair);
578 if (!valid_path(r, path_pair)) {
579 DBG(r, "invalid path. path_pair:[%s]", path_pair);
584 if (!valid_expires(r, expire_pair)) {
585 DBG(r, "invalid expire. expire_pair:[%s]", expire_pair);
590 if (!valid_secure(r, secure_pair)) {
591 DBG(r, "invalid secure. secure_pair:[%s]", secure_pair);
595 DBG(r, "end check_valid_cookie_attribute() value:[%s]", value);
600 valid_domain(request_rec *r, const char *value)
606 char *p = apr_pstrdup(r->pool, value);
607 const char *host = apr_table_get(r->headers_in, HTTP_HOST);
609 DBG(r, "start valid_domain() value:[%s]", value);
610 DBG(r, "host:[%s]", host);
614 name = apr_strtok(p,"=", &pstat);
615 name = qs_trim_string(r->pool, name);
616 val = apr_strtok(NULL, "=", &pstat);
617 val = qs_trim_string(r->pool, val);
620 if (chxj_strcasenrcmp(r->pool, host, val, strlen(val))) {
621 DBG(r, "not match domain. host domain:[%s] vs value:[%s]", host, val);
625 DBG(r, "end valid_domain() value:[%s]", value);
630 valid_path(request_rec *r, const char *value)
632 char *p = apr_pstrdup(r->pool, value);
639 DBG(r, "start valid_path() unparsed_uri:[%s] value:[%s]", r->unparsed_uri, value);
640 if (chxj_starts_with(r->unparsed_uri, "http://")) {
641 uri = strchr(&r->unparsed_uri[sizeof("http://")], '/');
643 uri = apr_pstrdup(r->pool, uri);
646 else if (chxj_starts_with(r->unparsed_uri, "https://")) {
647 uri = strchr(&r->unparsed_uri[sizeof("https://")], '/');
649 uri = apr_pstrdup(r->pool, uri);
652 else if (chxj_starts_with(r->unparsed_uri, "/")) {
653 uri = apr_pstrdup(r->pool, r->unparsed_uri);
656 uri = apr_pstrdup(r->pool, "/");
659 if ((tmp = strchr(uri, '?'))) {
662 DBG(r, "uri=[%s]", uri);
663 name = apr_strtok(p, "=", &pstat);
664 val = apr_strtok(NULL, "=", &pstat);
665 name = qs_trim_string(r->pool, name);
666 val = qs_trim_string(r->pool, val);
667 DBG(r, "name=[%s] val=[%s]", name, val);
669 DBG(r, "val:[%s] vs uri:[%s]", val, uri);
670 if (! chxj_starts_with(uri, val)) {
671 DBG(r, "end valid_path() unparsed_uri:[%s] value:[%s] (false)", r->unparsed_uri, value);
674 DBG(r, "end valid_path() unparsed_uri:[%s] value:[%s] (true)", r->unparsed_uri, value);
679 valid_expires(request_rec *r, const char *value)
683 char *p = apr_pstrdup(r->pool, value);
687 DBG(r, "start valid_expire() value:[%s]", value);
689 name = apr_strtok(p, "=", &pstat);
690 val = apr_strtok(NULL, "=", &pstat);
691 DBG(r, "name=[%s] val=[%s]", name, val);
692 now = apr_time_now();
693 expires = chxj_parse_cookie_expires(val);
694 DBG(r, "now=[%lld] expires=[%lld]", now, expires);
696 DBG(r, "end valid_expire() value:[%s] (expired)", value);
700 DBG(r, "end valid_expire() value:[%s] (non expired)", value);
705 valid_secure(request_rec *r, const char *value)
708 DBG(r, "start valid_secure() value:[%s]", value);
709 scheme = chxj_apache_run_http_scheme(r);
710 if (strcasecmp("https", scheme)) {
711 DBG(r, "end valid_secure() value:[%s] (non secure)", value);
714 DBG(r, "end valid_secure() value:[%s] (secure)", value);
720 chxj_add_cookie_parameter(request_rec* r, char* value, cookie_t* cookie)
725 DBG(r, "start chxj_add_cookie_parameter() cookie_id=[%s]", (cookie) ? cookie->cookie_id : NULL);
727 dst = apr_pstrdup(r->pool, value);
732 if (!cookie->cookie_id)
735 if (chxj_cookie_check_host(r, value) != 0) {
736 DBG(r, "end chxj_add_cookie_parameter()(check host)");
740 qs = strchr(dst, '?');
742 dst = apr_psprintf(r->pool, "%s&%s=%s", dst, CHXJ_COOKIE_PARAM, cookie->cookie_id);
745 dst = apr_psprintf(r->pool, "%s?%s=%s", dst, CHXJ_COOKIE_PARAM, cookie->cookie_id);
748 DBG(r, "end chxj_add_cookie_parameter() dst=[%s]", dst);
753 DBG(r, "end chxj_add_cookie_parameter() (on_error)");
759 chxj_cookie_check_host(request_rec* r, char* value)
763 DBG(r, "hostname=[%s]", r->hostname);
765 hostnm = s_get_hostname_from_url(r, value);
767 if (strcasecmp(hostnm, r->hostname) == 0)
777 s_get_hostname_from_url(request_rec* r, char* value)
782 if (strncasecmp(value, "http://", 7) == 0 )
783 return s_cut_until_end_hostname(r, &value[7]);
785 if (strncasecmp(value, "https://", 8) == 0)
786 return s_cut_until_end_hostname(r, &value[8]);
793 s_cut_until_end_hostname(request_rec* r, char* value)
798 hostnm = sp = apr_pstrdup(r->pool, value);
800 if (*sp == '/'|| *sp == '?') {
811 chxj_delete_cookie(request_rec *r, const char *cookie_id)
814 mod_chxj_config *dconf;
816 DBG(r, "start chxj_delete_cookie()");
817 dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
819 #if defined(USE_MYSQL_COOKIE)
820 if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
821 if (! chxj_delete_cookie_mysql(r, dconf, cookie_id)) {
822 ERR(r, "failed: chxj_delete_cookie_mysql() cookie_id:[%s]", cookie_id);
823 DBG(r, "end chxj_delete_cookie()");
830 #if defined(USE_MEMCACHE_COOKIE)
831 if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
832 if (! chxj_delete_cookie_memcache(r, dconf, cookie_id)) {
833 ERR(r, "failed: chxj_delete_cookie_memcache() cookie_id:[%s]", cookie_id);
834 DBG(r, "end chxj_delete_cookie()");
840 if (!done_proc || IS_COOKIE_STORE_DBM(dconf->cookie_store_type)) {
841 if (! chxj_delete_cookie_dbm(r, dconf, cookie_id)) {
842 ERR(r, "failed: chxj_delete_cookie_dbm() cookie_id:[%s]", cookie_id);
843 DBG(r, "end chxj_delete_cookie()");
848 DBG(r, "end chxj_delete_cookie()");
856 chxj_save_cookie_expire(request_rec* r, cookie_t* cookie)
859 mod_chxj_config *dconf;
861 DBG(r, "start chxj_save_cookie_expire()");
863 DBG(r, "cookie is NULL");
866 if (!cookie->cookie_id) {
867 DBG(r, "cookie->cookie_id is NULL");
871 dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
873 DBG(r, "dconf is NULL");
877 #if defined(USE_MYSQL_COOKIE)
878 if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
879 if (! chxj_save_cookie_expire_mysql(r, dconf, cookie->cookie_id)) {
880 ERR(r, "failed: chxj_save_cookie_expire_mysql() cookie_id:[%s]", cookie->cookie_id);
881 DBG(r, "end chxj_save_cookie_expire()");
887 #if defined(USE_MEMCACHE_COOKIE)
888 if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
889 if (! chxj_save_cookie_expire_memcache(r, dconf, cookie->cookie_id)) {
890 ERR(r, "failed: chxj_save_cookie_expire_memcache() cookie_id:[%s]", cookie->cookie_id);
891 DBG(r, "end chxj_save_cookie_expire()");
897 if (!done_proc || IS_COOKIE_STORE_DBM(dconf->cookie_store_type)) {
898 if (! chxj_save_cookie_expire_dbm(r, dconf, cookie->cookie_id)) {
899 ERR(r, "failed: chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie->cookie_id);
900 DBG(r, "end chxj_save_cookie_expire()");
905 DBG(r, "end chxj_save_cookie_expire()");
913 chxj_delete_cookie_expire(request_rec* r, char* cookie_id)
916 mod_chxj_config* dconf;
918 DBG(r, "start chxj_delete_cookie_expire()");
920 dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
922 #if defined(USE_MYSQL_COOKIE)
923 if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
924 if (! chxj_delete_cookie_expire_mysql(r, dconf, cookie_id)) {
925 ERR(r, "failed: chxj_delete_cookie_expire_mysql() cookie_id:[%s]", cookie_id);
931 #if defined(USE_MEMCACHE_COOKIE)
932 if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
933 if (!chxj_delete_cookie_expire_memcache(r, dconf, cookie_id)) {
934 ERR(r, "failed: chxj_delete_cookie_expire_memcache() cookie_id:[%s]", cookie_id);
940 if (!done_proc || IS_COOKIE_STORE_DBM(dconf->cookie_store_type)) {
941 if (!chxj_delete_cookie_expire_dbm(r, dconf, cookie_id)) {
942 ERR(r, "failed: chxj_delete_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
947 DBG(r, "end chxj_delete_cookie_expire()");
954 chxj_cookie_expire_gc(request_rec* r)
956 mod_chxj_config *dconf;
959 DBG(r, "start chxj_cookie_expire_gc()");
961 dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
962 #if defined(USE_MYSQL_COOKIE)
963 if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
964 if (! chxj_cookie_expire_gc_mysql(r, dconf)) {
965 ERR(r, "failed: chxj_cookie_expire_gc_mysql()");
971 #if defined(USE_MEMCACHE_COOKIE)
972 if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
973 if (! chxj_cookie_expire_gc_memcache(r, dconf)) {
974 ERR(r, "failed: chxj_cookie_expire_gc_memcache()");
981 if (! chxj_cookie_expire_gc_dbm(r, dconf)) {
982 ERR(r, "failed: chxj_cookie_expire_gc_dbm()");
986 DBG(r, "end chxj_cookie_expire_gc()");
990 chxj_parse_cookie_expires(const char *s)
992 if (!s) return (apr_time_t)0;
993 return apr_date_parse_rfc(s);