session.auto_start | 0鐚??≦?刻? | ???????鴻????紮???? ?祉???激?с?潟?≪?吾?ャ?若?????祉???激?с?潟????????????紮?????????????????絎?????????1?????????鴻???????????祉???激?с?割戎????????session_start()???∽?違??絎h??????????篏睡???с???????????????? |
session.cache_limiter | nocache | ?祉???激?с?潟???若?吾???????????c???激?ュ?九勝???号?????絎? (none/nocache/private/private_no_expire/public) |
session.cache_expire | 180 | ???c???激?ャ???????祉???激?с?潟???若?吾?????号??????????篏??ф??絎? |
session.cookie_lifetime | 0鐚????????吟?????????障?э? | ???????吟????篆<???????????若?????号??????腱???篏??ф??絎? |
session.cookie_path | / | session_cokkie?ц┃絎????????鴻????絎? |
session.cookie_domain | 腥堺??絖? | ???????若?????鴻?????????<?ゃ?潟???????????????祉???????????????????????????泣?若????????????????????若?????c?????障????????????abc.com ????絎?????????www.abc.com, private.abc.com ?????????????若????????????????鐚?session.cookie_path ?ф??絎????????鴻????筝??眼?????逸??? |
session.cookie_secure | off | ?祉???ャ?≪??・膓?????????????ookie????篆<?с????????????????絎? |
session.entropy_file | 腥堺??絖? | ?祉???激?с??D??篏????????????ャ?????潟???????純?若?鴻??????戎??????紊??????純?若?鴻?吾?????鴻????絎???箴???????????紊????NIX?у??????純??dev/random?障????dev/urandom???????????障???? |
session.entropy_length | 0 | session.entropy_file?????<?ゃ?????? 茯??帥???????ゃ???違????絎? |
session.gc_probability | 1 | ???若???吾?潟?????激?с?潟???莨若?水?ゃ??┃絎??с???????????鴻??罸???????????罸??????祉???激?с?喝????????? gc (???若???吾?潟?????激?с???∽?違????紮????障???????若???吾?潟?????激?с?潟???莨若?水?ゃ?????若?祉?潟???ф??絎????障???? |
session.gc_divisor | 100 | session.gc_divisor? session.gc_probability????水??????с???鴻?????祉???激?с?潟?????????????c鐚????若?????吾?潟?????激?с?鰹??????祉?鴻??紮???????腆榊????九勝???障????腆榊???c_probability/gc_divisor?ц?膊??????障????箴????違??1/100???????????鴻??罸???%??∈????C?????祉?鴻?? 紮??????障???? |
session.gc_maxlifetime | 1440 | ???若?帥???????帥?????帥????????羔??祉???????障?с????違????絎????障???? |
session.hash_function | 0 | ????激?ョ?????∽?違????絎?鐚?0:MD5/1:SHA鐚? |
session.hash_bits_per_character | 4 | 1??絖?罸???????激?ャ??????? (4/5/6) |
session.name | PHPSESSID | ?祉???激?с?喝??????絎????????????弱????????戎???????障?????≪?????<????????絖????帥?ф??絎?????綽?荀????????障???? |
session.referer_check | 腥堺??絖? | HTTP Referer ????????∈茯???茵?????絖???????絎????障????Referer???????ゃ?≪?潟??????????篆<???????????????ゃ????絎???????絖?????荀?篁??????????翫????????莨若?障?????祉???激?с??D???≦?鴻???????障???? |
session.save_path | /tmp | ?祉???激?с?潟???主????????宴??篆?絖????????<?ゃ????篏??????????贋???????鴻??1???<?ゃ?潟?ц??違??eb?泣?若???ч???????????????演?????≪???祉?鴻?с????????????????絎??????????????????с?祉???激?с?潟???掩?????с?????? |
session.serialize_handler | php | ?激???≪?????障?????激???≪???????若?帥??緇?????????????戎??????????潟????????????絎?臂 |
session.use_cookies | 1鐚????刻? | ?????ゃ?≪?潟???眼???祉?? ?激?с??D??篆?絖????????????????若??篏睡??????????????????絎? |
session.use_only_cookies | 0鐚??≦?刻? | ?????≪?吾?ャ?若?????????ゃ?≪?潟???眼?吾???祉???激?с??D???絖???ookie???帥??篏睡??????????????絎? |
session.use_trans_sid | 0鐚??≦?刻? | ?祉???激?с?潟??????????祉???激?с??D(SID)????????????????????????絎? |
session.bug_compat | ||
session.bug_compat_42 |
DB, memcached 膈???篏帥?c???祉???激?с?括?????茵????翫??????篁ヤ????鴻??絵???????
register_shutdown_function('session_write_close');
?祉???激?с?括??????????若??????篏????????????祉???激?с?潟??潟??????絎?臂???????
?? ???若??? sessions
CREATE TABLE `sessions` ( `id` varchar(32) NOT NULL default '', `access` int(10) unsigned default NULL, `data` text, PRIMARY KEY (`id`) ) TYPE=MyISAM;
?? session_mysql.ini
<?php define("SESSION_DB_HOST", "localhost"); define("SESSION_DB_USER", "test"); define("SESSION_DB_PASS", "test"); define("SESSION_DB_DB", "test"); ?>
?? session_mysql.php
<?php require_once("session_mysql.ini"); // ???若?九?臂????祉???激?с?潟??潟??????篏睡? ini_set("session.save_handler", "user") or die("ini_set(session.save_handler) failed."); // ?祉???激?с?潟??潟?????∽?違??荐?? session_set_save_handler('_open', '_close', '_read', '_write', '_destroy', '_clean'); // PHP5.0.5 篁ラ??? session_start() ???若?九?????????????絎?茵? register_shutdown_function('session_write_close'); function _open() { global $_sess_db; $db_host = SESSION_DB_HOST; $db_user = SESSION_DB_USER; $db_pass = SESSION_DB_PASS; $db_db = SESSION_DB_DB; if ($_sess_db = mysql_connect($db_host, $db_user, $db_pass)) { return mysql_select_db($db_db, $_sess_db); } return FALSE; } function _close() { global $_sess_db; return mysql_close($_sess_db); } function _read($id) { global $_sess_db; $id = mysql_real_escape_string($id); $sql = "SELECT data FROM sessions WHERE id = '$id'"; if ($result = mysql_query($sql, $_sess_db)) { if (mysql_num_rows($result)) { $record = mysql_fetch_assoc($result); return $record['data']; } } return ''; } function _write($id, $data) { global $_sess_db; $access = time(); $id = mysql_real_escape_string($id); $access = mysql_real_escape_string($access); $data = mysql_real_escape_string($data); $sql = "REPLACE INTO sessions VALUES ('$id', '$access', '$data')"; return mysql_query($sql, $_sess_db); } function _destroy($id) { global $_sess_db; $id = mysql_real_escape_string($id); $sql = "DELETE FROM sessions WHERE id = '$id'"; return mysql_query($sql, $_sess_db); } function _clean($max) { global $_sess_db; $old = time() - $max; $old = mysql_real_escape_string($old); $sql = "DELETE FROM sessions WHERE access < '$old'"; return mysql_query($sql, $_sess_db); } ?>
?? test.php
<?php require_once("session_mysql.php"); // Initialize a session. This call either creates // a new session or re-establishes an existing one. session_start(); // If this is a new session, then the variable // $count will not be registered if (!session_is_registered("count")) { session_register("count"); session_register("start"); $count = 0; $start = time(); } else { $count = $_SESSION['count']; $start = $_SESSION['start']; $count++; } $sessionId = session_id(); $_SESSION['count'] = $count; $_SESSION['start'] = $start; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <html> <head><title>Sessions</title></head> <body> <p>This page points at a session (<%= $sessionId %>) <br>count = <%= $count %>. <br>start = <%= $start %>. <p>This session has lasted <?php $duration = time() - $start; echo "$duration"; ?> seconds. <p><a href="destroy_session.php">destroy session</a> </body> </html>
memcached ???泣?若?????<?≪????????若?帥???主????????閟?罕?????箴????????若???????≪???帥?ゃ???????若?帥?с????綽?荀??????????若?帥???????主??????????号????????????荐???с????????????
extension_dir = "/usr/local/lib/php/extensions"
$ pecl install memcache
extension=no-debug-non-zts-20060613/memcache.so
Mac OS X 筝??с?????ゃ??????????≫??с???障????????с???????c?????????荐若??????????????