[php]使用會話session

來源:互聯網
上載者:User

標籤:blog   io   ar   使用   on   檔案   div   art   log   

<?php/*  cookie - 在用戶端上儲存少了資訊(cookie) session(會話) - 解決cookie大小限制/數量/其他  setcookie() - 設定cookie 在用戶端產生cookie檔案,可以保持:到期時間;名稱;值...  *  */setcookie(‘name‘,‘Lee‘,time()+(7*24*60*60));/*  * 讀取cookie *  */if(isset($_COOKIE[‘name‘])){echo $_COOKIE[‘name‘];}/*  * 刪除cookie *  *  */if(isset($_COOKIE["name"])){setcookie("name","");setcookie("name","Lee",time()-1);}/*  * cookie 的使用限制: * 1. 必須 在html檔案內容 輸出{之前}  設定; * 2. 不同的瀏覽器 對 cookie的處理  (不一致); * 3. 限制是在用戶端的. * 一個瀏覽器最多能建立[30個]cookie; * 每個cookie不能超過4KB; * 每個web網站能設定的cookie總數不能超過20個. *  *  *//* Session會話 *//*  用 session_start() 開始{會話}. *  */// 建立session 並 讀取sessionsession_start();echo "<br>";$_SESSION[‘name‘]="Leee";echo $_SESSION["name"];// 設定好的session馬上就能用/* 判斷session 是否存在? */// session_start();$_SESSION["name"]="LEEe";if(isset($_SESSION["name"])){echo $_SESSION["name"];}?>

  

[php]使用會話session

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.