1

I need to pass php session variables from my php form to a perl script and vice versa so the forms fields can keep their values.

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>

My question is how could i do it in the perl side

Imane Fateh
  • 2,418
  • 3
  • 19
  • 23

2 Answers2

0

The answer was simple, in the perl side :

use CGI qw/:standard/;         
use CGI::Cookie;
%cookies = CGI::Cookie->parse($ENV{COOKIE});
Imane Fateh
  • 2,418
  • 3
  • 19
  • 23
-1

Have you searched already? I don't think so...

Passing variables from PHP to PERL

You need to use exec:

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

Other link:

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

Community
  • 1
  • 1
eL-Prova
  • 1,084
  • 11
  • 27
  • I searched already, i can pass variables from php to perl, it is not my question, my question is how to pass cookies/sessions variables... – Imane Fateh Apr 18 '13 at 10:18