在Perl中创建会话并在PHP中读取会话变量

I have a Perl script that tries to make a post request to a PHP server. Used LWP::UserAgent for post request and CGI::Session to handle sessions.

Right now, no big issue on post, but after set session variable: username in Perl, I could not get value from $_SESSION['username']. Tried using PHP::Session, no luck neither.

Perl:

use strict;
use warnings;

use CGI;
use CGI::Session;
use LWP::UserAgent;

my $cgi = CGI->new();
my $session = CGI::Session->new( 'serializer:php' );
$session->param('username', 'dev');
print "::Perl session id::" . $session->id() . "::
";

my $browser = LWP::UserAgent->new;
my $url = 'http://localhost/test.php';
my $response = $browser->post( $url,
  [ 
    'date' => '2015-02-25'
  ]
);

die "$url error: ", $response->status_line
 unless $response->is_success;

my $file_data = $response->content();
print $file_data;

Php:

<?php
session_start();
echo "::PHP session id::" . session_id() . "::
";
echo "::" . $_POST['date'] . "::
";
echo "::" . $_SESSION['username'] . "::
";    
?>

By executing Perl script, I get output:

::Perl session id::737ba07ad1a2ced0be07cd303cf08afe::
::PHP session id::ri60ivtb32lglcrqv4ug1sb2i5::
::2015-02-25::
::::

$_SESSION['username'] is not retrieved correctly. And session ids are different.

I did not find an ideal module for Perl to handle SFTP/FTP on windows. Instead, get some luck using Win32::OLE->new('WinSCP.Session').

Usage: http://winscp.net/eng/docs/library_perl