PHP Session Cross-page Transfer session value loss problem

Source: Internet
Author: User
Tags php session

1, Session_Start (); should be placed at the top of the page as far as possible;2if there is no session autostart in the php.ini, the Session:session_start () must be opened manually before each conversation.3, SESSION is a super global variable inside PHP, like $_get,$_post,$_server, so use must capitalize: $_session['username']=$username;4, cross-page Delivery Example: a.php page Delivery $_session['username'] to b.php:a.php--------------<?php session_start (); Open session $username=$_post['username']; Receive variable $_session['username']=$username;//Save variable to session?>b.php
--------------<?php session_start (); Open session (Here the session does not open, is not to get the value of the session) Echo $_session['username']; Output the variables in the session?>

PHP Session Cross-page Transfer session value loss problem

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.