user1544207
user1544207

Reputation: 60

perl cgi won't access php session data in /tmp

I am trying to gain access to an existing php session from a perl script. I can see sample of php to perl, but not perl to php. My biggest issue is accessing the /tmp directory correctly. I have all the proper permissions, I just cannot find how to capture the session. I see all of the /tmp/sess~ files but I cannot find anything close to a working example to show me how to get to it.

#!/usr/bin/perl
# Script to launch the vncserver service and capture output
# Runs, displays $pid to STDOUT, but opened
# files are empty.

use strict;
use warnings;
use CGI qw();
use CGI::Session qw();

my %vars = (
    COOKIE_NAME => '_SESSION',
    SESSION_DIR => '/tmp',
);
my $q = CGI->new;
print $q->header;
CGI::Session->name($vars{COOKIE_NAME});
my $session = CGI::Session->new('id:md5', $q, {Directory=>$vars{'/tmp/'}});

print $session->header(-type => 'text/plain');


my $system_name  = $session->param("_SESSION_ATIME");
print $system_name->output();

Upvotes: 0

Views: 665

Answers (1)

Quentin
Quentin

Reputation: 944568

There are lots of ways that session data could be stored. PHP uses one way. CGI::Session uses another. You can't use CGI::Session to read PHP sessions. Use PHP::Session instead.

Upvotes: 3

Related Questions