CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
how to store class object in perl session

 



pavan538
New User

Dec 28, 2012, 7:23 PM

Post #1 of 2 (2486 views)
how to store class object in perl session Can't Post

Emp.pm

Package Emp;
sub new {
my($class,$args )=@_;
my $self = bless{},$class;
$self->{name}=args->name;
$self->{id}=args->id;
return $self;
}
sub getName{
$self=shift;
return $self->{name};
}


thers is one session object

$session = new $session("driver::file",undef,{Directory=>"/tmp"};
$emp = new Emp({name=>'pavan',id=>101});
session->param("emp",$emp);

but it i open the session file from tmp directory it shows undef for emp.

is it possible to store the entire object of emp in session?


(This post was edited by pavan538 on Dec 28, 2012, 7:25 PM)


wickedxter
User

Dec 29, 2012, 5:34 PM

Post #2 of 2 (2448 views)
Re: [pavan538] how to store class object in perl session [In reply to] Can't Post


Code
 
#this correct new $session?
$session = new $session("driver::file",undef,{Directory=>"/tmp"};
$emp = new Emp({name=>'pavan',id=>101});
session->param("emp",$emp);



the object is just a perl data tree, so yes you should. What session module are you useing?

look in to this http://perldoc.perl.org/Storable.html


(This post was edited by wickedxter on Dec 29, 2012, 5:42 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives