#!/usr/bin/perl
#this part grabs the PHPSESSID cookie from the users computer
$myCookie = $ENV{'HTTP_COOKIE'};
#this part splits the cookie apart so you can use just the hex number
#ex: PHPSESSID=24ef64917dcbe19730b184a8fe37449d would be the user's cookie
#this array will set the LONG hex value to $cookie[1]
@=split(/=/, $myCookie);
#this opens the actual PHPSESSID on the server computer
#you need to know the path to where session id's are stored
#session id files look like 'sess_24ef64917dcbe19730b184a8fe37449d' on the server side
open(SESSION,"/tmp/sess_$cookie[1]");
$mysess = <SESSION>;
close(SESSION);
#just to note, $mysess ended up looking like this, but with more values:
#clientID|s:1:"1";fname|s:4:"Dave";lname|s:8:"Baughman";email|s:25:"dbaughman@ca
rpeclicks.com";
#split up each section of the PHPSESSID into an array called @line
@line = split(/\;/, $mysess);
#takes each item in the array @line and runs a regular expression
#on it to extract each value in the of the session ID.
#This way makes it easier to remember what variables are what as opposed to the
#scalar array I was using before.
foreach $item(@line) {
chomp $item;
$item =~ s/(.+?)|.\"(.+?)\"./$1|$2/isg;
($name, $value) = split(/|/, $item);
$php{$name} = $value;
}
###################
Then just call the session variable you want by using $php{variablename} in your perl script. Thanks a million, Steve.