Wordpress中的PHP会话无法正常工作

I'm trying to transfer value "text1" from one page to another on Wordpress but can't get it working. After submit from First page to Second page Session array on second page appears to be empty.

First Page

<?php 
session_start();
$_SESSION['text1'] = $_POST['text1'];
?>

<?php 
if(isset($_POST['submitted'])) {
header("Location: ?page_id=5327"); 
} ?>

<form id="contactForm" action="http://www.bpetrade.com/?page_id=5327" method="post">
<input name="text" type="text" />
<input type="submit" />
<input id="submitted" name="submitted" type="hidden" value="true" />
</form>

Second page

<?php print_r($_SESSION); ?>

And it returns empty array on second page.

I think you have to start session on second page as well and your input name is text any you are trying to set $_POST['text1'] to your session variable.

You should start session on each page.

Just add session_start(); to first line on second page

Even if you use function session_start you will get into header already sent Warning.

So you will need to start session in init hook check How to use session in wordpress in plugin development