首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 網頁程式設計 >> ASP 程式設計 >> ASP 入門教學

ASP 入門教學:Session 物件儲存會話資訊完整指南

     編輯:ASP 入門教學

Contents 集合 - 會話變數儲存

Session.Contents("key") 與 Session("key") 等價。簡易計數器:

Session.Contents("counter") = Session.Contents("counter") + 1
Response.Write "您是第 " & Session.Contents("counter") & " 次來訪!"

StaticObjects 集合 - 會話層級物件

在 global.asa 宣告:

<OBJECT RUNAT="Server" SCOPE="Session" ID="MyObj" PROGID="Some.Component"></OBJECT>

遍歷:

For Each obj In Session.StaticObjects
    Response.Write obj & ": " & Session.StaticObjects(obj) & "<br>"
Next

重要限制

  • 不可儲存內建物件:Session、Request、Response、Server、Application
  • 嘗試指派會拋出錯誤

Session 物件提供用戶層級資料隔離,是購物車、登入狀態、個人化設定等功能的核心基礎設施。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved