chapter 10-03

Cookie 的資料 (網頁端)

此章節說明網頁程式可以取得哪些 cookie 資料.


網頁的編碼格式必須是 UTF-8, 如下的宣告 :
<meta http-equiv="content-type" content="text/html; charset=utf-8">


需要的 JS 檔 :
jquery_main.js
jquery_cookie.js



使用方式

登入成功後, MintAAM 會傳送以下的 cookie 資料給瀏覽器 :
[session_key]
登入的使用者的識別資料 (MintAAM 產生的隨機字串).
[account_name]
登入的帳號的名稱. [詳細]
[account_permission]
登入的帳號的權限. [詳細]

使用 jquery 的 $.cookie() 函式取出 cookie 的值.

範例 :
// 取出 session_key.
console.log("session_key = ", $.cookie("session_key"));
// 取出 account_name.
console.log("account_name = ", $.cookie("account_name"));
// 取出 account_permission.
console.log("account_permission = ", $.cookie("account_permission"));



範例程式的使用

01.  範例程式目錄在 mint_cm/usage/example/1003.


02.  下面關於 make 的操作沒有特別註明的話都是在 mint_cm 目錄.


03.  第一次使用, 使用 make example_add KEY=1003 載入範例並編譯.


04.  web_app 是範例程式.

範例項目 :
case-01 測試取得 cookie


05.  先執行 mcm_daemon 和 mini_httpd 才可測試.


06.  瀏覽器連至 http://<server-address> 會自動導到登入頁面.


07.  測試完畢不使用後, 使用 make example_del KEY=1003 將範例移除.


08.  範例程式目錄下的檔案在做完 make example_add 後會複製到真正使用的位置, 要修改做測試的話要改在複製後的.
來源 profile/mcm_data_profile_1003.xml
目地 mint_cm/mcm_build/mcm_data_profile.xml
資料模型範例
有修改要使用 make all 重新編譯
來源 profile/mcm_store_profile_default_1003.txt
目地 mint_cm/mcm_build/mcm_store_profile_default.txt
資料預設值範例
使用 make all 後會再複製到 mint_cm/run
來源 web_app
目地 mint_cm/run/web
網頁程式範例
來源 maam_buildin
目地 http_server/mini_httpd/last/mint_aam/maam_buildin
MintAAM 端範例範例
有修改要使用 make all 重新編譯
來源 mini_httpd/Makefile
目地 http_server/mini_httpd/last
mini_httpd 的 Makefile, 主要是加入使用 MintCM 函式庫的連結
有修改要使用 make all 重新編譯