easyrecovery professional php4的session功能評述(一)

來源:互聯網
上載者:User
php4比php3新加了session的支援。稍微用了一下,對其函數介面,內部機制,
應用的方便性做了大概的瞭解。
session的意義大家都應該清楚,一個session可以包括數次http的請求和應答,
比如我們用163.net,從login到logout或者逾時就作為一個session,session
的唯一標識一般是在系統內部產生一個唯一的session ID,一般是一個挺長的
字串。一個session除了session ID,還可以有自己的session data,可以
記錄和區分sesion的不同狀態。
php4對session操作提供以下介面:
session_start — Initialize session data
session_destroy — Destroys all data registered to a session
session_name — Get and/or set the current session name
session_module_name — Get and/or set the current session module
session_save_path — Get and/or set the current session save path
session_id — Get and/or set the current session id
session_register — Register a variable with the current session
session_unregister — Unregister a variable from the current session
session_is_registered — Find out if a variable is registered in a session
session_decode — Decodes session data from a string
session_encode — Encodes the current session data as a string
意義大家一看就能明白,session_start開始一個session,session_destroy結
束一個session,session_id取得當前的session_id,session_register向當前
的session註冊一個變數,這個很有用,比如使用者逛商場,選中了某幾樣商品你
就可以用session_register把商品名稱或者代碼register到當前的session中。
比如下面例子(摘自php manual):
session_register("count");
$count++;
?>
Hello visitor, you have seen this page times.


# the is necessary to preserve the session id
# in the case that the user has disabled cookies
To continue, ">click here
session_register可以隱式地激發session_start(如果使用者之前沒發session_
start調用),當前的session註冊了一個變數count,每次使用者點擊click here
的時候,這個變數都會增一。你可以自己試一下。的意義不多贅述。

以上就介紹了easyrecovery professional php4的session功能評述(一),包括了easyrecovery professional方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.