How to use session_start ()

Source: Internet
Author: User
How to use session_start? At the end of this post, xwmr1988 was used to edit session. auto_start0 page 1 index. php: & lt;? in php. ini from 2013-11-0516: 07: 59 ;? Php & nbsp; session_start ();? & Gt; & lt ;? How to use phpif (isset ($ _ POST [submi session_start?

This post was last edited by xwmr1988 at 16:07:59, January 5 ,.

Session. auto_start = 0 in php. ini
Page 1 index. php:


If (isset ($ _ POST ['submit ']) {
$ _ SESSION ['Season '] =_ _ POST ['Season'];
Header ('Location: test. php ');
}
?>
Storage session

Select the data to be set:


Page 2 test. php:

Session_start ();
?>
$ Season = $ _ SESSION ['Season '];
Echo'Read session ';
Switch ($ season ){
Case 'spring ':
Echo 'green spring now ';
Break;
Case 'Summer ':
Echo 'the summer is full of enthusiasm now ';
Break;
Case 'loan ':
Echo 'The autumn is fruitful now ';
Break;
Case 'Winter ':
Echo 'snow-white winter now ';
Break;
Default:
Echo 'Sorry, the session does not contain data or does not exist. ';
}
?>

Run Page 1:

Submit to page 2:

Why does this warning appear? How can this problem be solved? Besides setting session. auto_start = 1

Share:


------ Solution --------------------
Check that test. php does not have a bom header.

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.