将会话变量从php传递给perl

时间:2013-04-18 09:41:29

标签: php perl post cookies cgi

我需要将php会话变量从我的php表单传递到perl脚本,反之亦然,这样表单字段可以保留它们的值。

form.php的

<?php  session_start();
 if (isset($_POST['submit'])){
    $post_arr = $_POST;

    $expire = 8*3600; 
    setcookie("Cookie_Info", serialize($post_arr), time()+$expire); 
   }

if (isset($_COOKIE['Cookie_Info'])) {
    $data = unserialize($_COOKIE['Cookie_Info']);
} else {
    $data = array(
          'from' => '',
              'area_html' => ''
    );

        }

.....

<form name="sendForm" method="post" action="test.cgi" >
<tr><td> from: </td>
    <td><input type="text" name="from" value="<?php echo $data->from; ?>"/></td>
</tr>

我的问题是如何在perl方面做到这一点

2 个答案:

答案 0 :(得分:0)

答案很简单,在perl方面:

use CGI qw/:standard/;         
use CGI::Cookie;
%cookies = CGI::Cookie->parse($ENV{COOKIE});

答案 1 :(得分:-1)

你已经搜索过吗?我不这么认为......

Passing variables from PHP to PERL

您需要使用exec:

<?php
$var1='high'; 
exec('C:/xampp/htdocs/WORK/hello.pl'.' '.EscapeShellArg("$var1"),$output);
echo ($output);
?>

其他链接:

http://forums.devshed.com/php-development-5/passing-arrays-from-php-to-a-perl-script-run-as-35600.html

相关问题