日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

詳解PHP會話存儲方式_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:cmd運(yùn)行php
打開 命令提示符 cmd.exe E:wampbinphpphp5.2.6php.exe a.php 11 11是傳參數(shù) 獲取 if($argv[1]){ $_GET['id']=$argv[1]; } echo $id=$_GET[id]+1; 你可以將 a.php 改成你的文件名, 注意目錄結(jié)構(gòu) 我這里直接使用 a.php 是因?yàn)?a.php 與 php.exe 是在同一個目錄下 為了方

  先確認(rèn)會話是否自動開啟還是需要通過session_start()來手動開啟:

  ; 指定會話模塊是否在請求開始時自動啟動一個會話。默認(rèn)為 0(不啟動)

  ; Initialize session on request startup.

  ; http://php.net/session.auto-start

  session.auto_start = 0

  在客戶端,會話可以存儲在cookie或者通過URL參數(shù)來獲取。依賴于服務(wù)器的配置:

  ; 指定是否在客戶端用 cookie 來存放會話 ID。默認(rèn)為 1(啟用)

  ; Whether to use cookies.

  ; http://php.net/session.use-cookies

  session.use_cookies = 1

  ; 指定是否在客戶端僅僅使用 cookie 來存放會話 ID。。啟用此設(shè)定可以防止有關(guān)通過 URL 傳遞會話 ID 的攻擊。

  ; This option forces PHP to fetch and use a cookie for storing and maintaining

  ; the session id. We encourage this operation as it's very helpful in combatting

  ; session hijacking when not specifying and managing your own session id. It is

  ; not the end all be all of session hijacking defense, but it's a good start.

  ; http://php.net/session.use-only-cookies

  session.use_only_cookies = 1

  如果確認(rèn)存儲在cookie中,則可以進(jìn)一點(diǎn)配置會話存儲在cookie中的各項(xiàng)配置,如cookie_name,cookie_lifetime,cookie_path,cookie_domain,cookie_secure,cookie_httponly

  ; Name of the session (used as cookie name).

  ; http://php.net/session.name

  session.name = PHPSESSID

  ; Lifetime in seconds of cookie or, if 0, until browser is restarted.

  ; http://php.net/session.cookie-lifetime

  session.cookie_lifetime = 0

  ; The path for which the cookie is valid.

  ; http://php.net/session.cookie-path

  session.cookie_path = /

  ; The domain for which the cookie is valid.

  ; http://php.net/session.cookie-domain

  session.cookie_domain =

  ; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.

  ; http://php.net/session.cookie-httponly

  session.cookie_httponly =

  在服務(wù)器端,同樣也可以通過多種方式來存儲會話。默認(rèn)會話存儲在文件中,此時session.save_path為創(chuàng)建存儲文件的路徑。

  ; Handler used to store/retrieve data.

  ; http://php.net/session.save-handler

  session.save_handler = files

  ; Argument passed to save_handler. In the case of files, this is the path

  ; where data files are stored. Note: Windows users have to change this

  ; variable in order to use PHP

  's session functions.

  ;

  ; The path can be defined as:

  ;

  ; session.save_path = "N;/path"

  ;

  ; where N is an integer. Instead of storing all the session files in

  ; /path, what this will do is use subdirectories N-levels deep, and

  ; store the session data in those directories. This is useful if you

  ; or your OS have problems with lots of files in one directory, and is

  ; a more efficient layout for servers that handle lots of sessions.

  ;

  ; NOTE 1: PHP will not create this directory structure automatically.

  ; You can use the script in the ext/session dir for that purpose.

  ; NOTE 2: See the section on garbage collection below if you choose to

  ; use subdirectories for session storage

  ;

  ; The file storage module creates files using mode 600 by default.

  ; You can change that by using

  ;

  ; session.save_path = "N;MODE;/path"

  ;

  ; where MODE is the octal representation of the mode. Note that this

  ; does not overwrite the process's umask.

  ; http://php.net/session.save-path

  ;session.save_path = "/tmp"

  PHP支持通過session_set_save_handler來實(shí)現(xiàn)會話處理器的自定義open, close, read, write, destroy, gc處理函數(shù),常見的會話處理器包括使用內(nèi)存型分配(如mm,memcache等),也可以使用數(shù)據(jù)庫進(jìn)行存儲。由此可見,若需要會話存儲與文件系統(tǒng)(例如用數(shù)據(jù)庫PostgreSQL Session Save Handler或默認(rèn)的文件存儲files)協(xié)同工作的,此時有可能造成用戶定制的會話處理器丟失了未存儲數(shù)據(jù)的會話。若使用內(nèi)存型分配存儲,又需要考慮會話持久化存儲問題。

  接下來重點(diǎn)講解memcache(d?)會話處理器。

  Memcache模塊提供了于memcached方便的面向過程及面向?qū)ο蟮慕涌�,memcached是為了降低動態(tài)web應(yīng)用 從數(shù)據(jù)庫加載數(shù)據(jù)而產(chǎn)生的一種常駐進(jìn)程緩存產(chǎn)品。

  Memcache模塊同時提供了一個session 處理器 (memcache).

  更多關(guān)于memcached的信息請參見» http://www.memcached.org/.

  memcached是一個高性能分布式的內(nèi)存對象緩存系統(tǒng), 通常被用于降低數(shù)據(jù)庫加載壓力以提高動態(tài)web應(yīng)用的響應(yīng)速度。

  此擴(kuò)展使用了libmemcached庫提供的api與memcached服務(wù)端進(jìn)行交互。它同樣提供了一個session處理器(memcached)。 它同時提供了一個session處理器(memcached)。

  關(guān)于libmemcached的更多信息可以在» http://libmemcached.org/libMemcached.html查看。

  memcache會話處理器配置:

  session.save_handler = memcache

  session.save_path = "tcp://127.0.0.1:11211?persistent=0&weight=1&timeout=1&retry_interval=15,tcp://127.0.0.1:11212?persistent=0&weight=1&timeout=1&retry_interval=15,tcp://127.0.0.1:11213?persistent=0&weight=1&timeout=1&retry_interval=15,tcp://127.0.0.1:11214?persistent=0&weight=1&timeout=1&retry_interval=15"

分享:php分析域名
php分析域名!寫法方法!調(diào)用就可以得出域名 ? //轉(zhuǎn)載保留來源于http://www.hake.cc/span // ####################### 分析域名 ####################### function phpzygetname($url) { $referer = preg_replace(/https?://([^/]+).*/i, \1, $url); $referer = str_re

共2頁上一頁12下一頁
來源:模板無憂//所屬分類:PHP教程/更新時間:2013-04-17
相關(guān)PHP教程