LoginSignup
2
0

More than 5 years have passed since last update.

Apache Moduleでcookieの使い方

Last updated at Posted at 2018-04-22

こっちのAPI使うのが正解っぽい。今私も勉強中...

apr_status_t    ap_cookie_write (request_rec *r, const char *name, const char *val, const char *attrs, long maxage,...) AP_FN_ATTR_SENTINEL

apr_status_t    ap_cookie_write2 (request_rec *r, const char *name2, const char *val, const char *attrs2, long maxage,...) AP_FN_ATTR_SENTINEL

apr_status_t    ap_cookie_remove (request_rec *r, const char *name, const char *attrs,...) AP_FN_ATTR_SENTINEL

apr_status_t    ap_cookie_remove2 (request_rec *r, const char *name2, const char *attrs2,...) AP_FN_ATTR_SENTINEL

apr_status_t    ap_cookie_read (request_rec *r, const char *name, const char **val, int remove)

apr_status_t    ap_cookie_check_string (const char *string)

以下ガセネタ注意

cookieの設定

apr_table_set(r->headers_out, "Set-Cookie", "hogehoge=0" );

cookieの取得

// 2回目はhogehoge=0が取れる1回目はNULL(nullptr)
const char* cookie = apr_table_get(r->headers_in, "Cookie"); 

知らなかったですけどcookieって文字列だったんですね。
自分でパースしなきゃならないのは面倒ですね…

次はセッション作りたいが考えないといけないですね。
こんなコアな部分今更作りたくない訳だけど...基本機能としてはないんですね。

追記
これはcookieじゃない…確かに値は保持してたけど、ブラウザ閉じても残ってる。
再調査します。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0