Session handler function sessions in PHP

Source: Internet
Author: User
<span id="Label3"></p>PHP Session variables<p><p><span style="font-size: 14px; font-family: ‘Microsoft YaHei‘;">When you run an application, you open it, make some changes, and then close it. It's like a Conversation. The computer knows who you are. It knows when you start the application and when it Terminates. But on the internet, there is a problem: the server does not know who you are and what you do, because the HTTP address does not maintain State.</span></p></p><p><p><span style="font-size: 14px; font-family: ‘Microsoft YaHei‘;">By storing user information on the server for later use, the PHP session solves the problem (such as user name, purchase of goods, etc.). however, The session information is temporary and will be deleted when the user leaves the Site. If you need to store information permanently, you can store the data in a Database.</span></p></p><p><p><span style="font-size: 14px; font-family: ‘Microsoft YaHei‘;">The Session works by creating a unique ID (UID) for each visitor and storing the variables based on this UID. The UID is stored in a cookie or transmitted through a URL.</span></p></p><p><p><span style="font-family: ‘Microsoft YaHei‘; font-size: 18pt;">1. Start a session</span></p></p><p><p><span style="font-family: ‘Microsoft YaHei‘; font-size: 14px;">Before you store the information in the session, start the Conversation. PHP provides the <span style="color: #ff0000;">session_start () function</span> to start or continue a Session. Defined:</span></p></p><p><p><span class="cnblogs_code"> <span style="color: #008080;">1</span> bool <span style="color: #008080;">session_start</span>(void)</span></p></p><p><p>The call is as Follows:</p></p><pre><pre><span style="color: #008080;">1</span> <span style="color: #0000ff;"><?</span> <span style="color: #ff00ff;">php session_start ();</span> <span style="color: #0000ff;">?></span> <span style="color: #008080;">2</span> <span style="color: #0000ff;"><</span> <span style="color: #800000;">HTML</span> <span style="color: #0000ff;">></span> <span style="color: #008080;">3</span> <span style="color: #0000ff;"><</span> <span style="color: #800000;">Body</span> <span style="color: #0000ff;">></</span> <span style="color: #800000;">Body</span> <span style="color: #0000ff;">></span> <span style="color: #008080;">4</span> <span style="color: #0000ff;"></</span> <span style="color: #800000;">HTML</span> <span style="color: #0000ff;">></span></pre></pre><p><p></p></p><p><p><span style="font-size: 14px; font-family: ‘Microsoft YaHei‘;">Attention:</span></p></p><p><p><span style="font-size: 14px; font-family: ‘Microsoft YaHei‘;">(1) the Session_Start () function <span style="color: #ff0000;">must precede the

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.