Learning the PHP session transmission method, phpsession
The example in this article shares three transfer methods of PHP session for your reference. The details are as follows:
Now that you have learned how to take notes and solve data sharing, don't worry about it. When should you manually set the cookie to be opened!
(1) pass session_id through GET
<? Php $ sid = "test"; // set the idsession_id ($ sid) of a session; // the value of $ sid is treated as session_id, which is convenient for testing session_start (); // enable session $ _ SESSION ['user'] = "session transfer method";?> <A href = "session_3.php? Sid = <? Php echo session_id ();?> "> Test_1.php </a> // process the effect of modifying different configuration items in the configuration file of php by passing the session_id value through GET. use_only_cookies = // disable this option. You can use get to automatically generate a session <a href = "session_3.php? PHPSESSID = <? Php echo session_id ();?> "> Test_1.php </a> // you can save yourself from getting the value session through $ _ GET. use_trans_sid = 1 // enable this option. session_id <a href = "session_2.php"> test_2.php </a> is automatically used. // No parameter is required, ========================================================== ===========< a href = "session_3.php <? Php echo "? ". SID;?> "> Test_1.php </a> the specific setting is a bit forgotten. SID is a constant and contains the required session information! // Session_3.php page session_id ($ _ GET ['sid ']); // accept sesssion_id; session_start (); var_dump ($ _ SESSION); // view the printed result
Result
(2) Pass the Hidden values in the form
// The previous public part remains unchanged // pass the <form action = "" method = "post"> name by hiding in the form: <input type = "text" name = "uname"> <input type = "hidden" name = "sid" value = "<? Php echo session_id ();?> "> <Input type =" submit "value =" OK "> </form> // $ sid =$ _ POST ['sid'] On the session_4 page; session_id ($ sid); session_start (); var_dump ($ _ SESSION); // you can view the printed results. The results are the same and no Repeated input results are returned.
(3) File Format
The above is all the content in this article. I hope you can learn more about the transfer method of PHP session.