You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by jonathan vanasco <jv...@mastersofbranding.com> on 2005/02/02 05:52:13 UTC

Storing Objects in a Session

slightly OT, but i'm doing this in mod_perl!

server
	Apache/2.0.52 (Unix)
	mod_perl/1.99_16
	Perl/v5.8.1

use
	use Apache::Cookie;
	use Apache::Request ();
	use Apache::Session;
	use Apache::Session::File;

is there any way to store an object into an Apache Session ?

all attempts have been fruitless.  i'd rather not rebuild the object by 
hand each time, but if needed i will.


Re: Storing Objects in a Session

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2005-02-02 at 12:26 -0500, Jonathan Vanasco wrote:
> I never thought of using storable.

There's no need for you to use Storable.  Apache::Session does it
already.  Just put your objects in the session.

> I thought i could just place an object in the tied session variable and 
> voila!

You can.

> I'm basically trying to store the UserProfile object into the session, 
> so I can use the methods I've made to access data in it rather than 
> accessing the data directly (ideally, so that less things break in the 
> future)

Okay, so what's not working about it?  Show us some code and some error
messages.

- Perrin


Re: Storing Objects in a Session

Posted by Jonathan Vanasco <jv...@mastersofbranding.com>.
On Feb 2, 2005, at 12:00 AM, David J Radunz wrote:
> Have you tried to freeze your object and then thaw it on retrieve?
>
> perl -MCPAN -e install Storable
> perldoc Storable

On Feb 2, 2005, at 12:28 AM, Perrin Harkins wrote:
> Yes, you put any object in Apache::Session as long as it can be 
> handled by Storable.  You'll need to tell us what you tried and what 
> didn't work about it before we can help you more.


I never thought of using storable.
I haven't actually done much work w/cookies and perl before
I thought i could just place an object in the tied session variable and 
voila!

I'll try some session storable stuff now --

I'm basically trying to store the UserProfile object into the session, 
so I can use the methods I've made to access data in it rather than 
accessing the data directly (ideally, so that less things break in the 
future)


Re: Storing Objects in a Session

Posted by David J Radunz <da...@staff.netspace.net.au>.
On Tue, 2005-02-01 at 23:52 -0500, jonathan vanasco wrote:
> slightly OT, but i'm doing this in mod_perl!
> 
> server
> 	Apache/2.0.52 (Unix)
> 	mod_perl/1.99_16
> 	Perl/v5.8.1
> 
> use
> 	use Apache::Cookie;
> 	use Apache::Request ();
> 	use Apache::Session;
> 	use Apache::Session::File;
> 
> is there any way to store an object into an Apache Session ?
> 

Have you tried to freeze your object and then thaw it on retrieve?

perl -MCPAN -e install Storable
perldoc Storable

> all attempts have been fruitless.  i'd rather not rebuild the object by 
> hand each time, but if needed i will.
> 

This email and any files transmitted with it are confidential and intended solely for the 
use of the individual or entity to whom they are addressed. Please notify the sender 
immediately by email if you have received this email by mistake and delete this email 
from your system. Please note that any views or opinions presented in this email are solely
 those of the author and do not necessarily represent those of the organisation. 
Finally, the recipient should check this email and any attachments for the presence of 
viruses. The organisation accepts no liability for any damage caused by any virus 
transmitted by this email. 


Re: Storing Objects in a Session

Posted by Perrin Harkins <pe...@elem.com>.
jonathan vanasco wrote:
> is there any way to store an object into an Apache Session ?

Yes, you put any object in Apache::Session as long as it can be handled 
by Storable.  You'll need to tell us what you tried and what didn't work 
about it before we can help you more.

- Perrin