zoukankan      html  css  js  c++  java
  • Session

    A session is a way to store information(in variables) to be used across multiple pages.Unlike a cookie, the information is not stored on the users computer.Session variables hold information about one single user, and are available to all pages in one application.

    Session variables are set with the PHP global variable: $_SESSION

    <!- start a PHP session -->

    <?php

    session_start();

    ?>

    <!DOCTYPE html>

    <html>

    <body>

    <?php 

    $_SESSION["favcolor"] = "green";

    $_SESSION["favanimal"] = "cat";

    echo "Session var are set";

    ?>

    </body>

    </html>

    <!-- get PHP session variable values -->

    <?php

    session_start();

    ?>

    <!DOCTYPE html>

    <html>

    <body>

    <?php

    echo "Favorite color is" .$_SESSION["favcolor"].  ".<br>";

    echo "Favorite animal is" .$_SESSION["favanimal"]. ".";

    ?>

    </body>

    </html>

    <!-- show all the session variable values -->

    <?php

    session_start();

    ?>

    <!DOCTYPE html>

    <html>

    <body>

    <?php

    print_r($_SESSION);

    ?>

    </body>

    </html> 

    <!-- modify PHP session variable -->

    <?php

    session_start();

    ?>

    <!DOCTYPE html>

    <html>

    <body>

    <?php

    $_SESSION["favcolor"] = "yellow";

    print_r($_SESSION);

    ?>

    </body>

    </html>

    <?php

    // remove all session variables

    session_unset();

    // destory the session

    session_destroy();

    ?>

    </body>

    </html>

  • 相关阅读:
    debian 登录CUPS 管理界面报错
    Shell脚本调试技术
    贴个ALSA例程
    产业生态圈和生态圈
    开个帖,开始学习shell编程
    Lua源码阅读建议
    Flash, EEPROM, SPI Flash diff
    makefile中的notdir,wildcard和patsubst
    quartus II使用零星记录
    Hello ZED
  • 原文地址:https://www.cnblogs.com/forerver-elf/p/5212076.html
Copyright © 2011-2022 走看看