You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by dhaval gada <dh...@gmail.com> on 2006/08/29 19:35:01 UTC

Request for Information

Hi,
 I am using Apache::Session  module for state persistence. However I
am getting the following error :


[1989]ERR: 24: Error in Perl code: Global data is not accessible: Died
at /usr/local/lib/site_perl/Apache/Session/Generate/MD5.pm line 40.

Atari 800 HTML::Embperl 1.3.6 [Fri Aug 25 11:18:35 2006]


If anyone could guide me on troubleshooting this, it would ge very helpful.


Thanks & Best Regards,
Dhaval.

Re: Request for Information

Posted by to...@tuxteam.de.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Sep 01, 2006 at 04:35:38PM -0400, dhaval gada wrote:
> Hi,
>  I am not using any references to subroutines in the session data.
> 
> And if some objects are implemented in Perl as references to subroutines,
> and
> some data structures include also subroutine references,
> then does it imply that no session management is possible with objects in
> embperl ???????????????

In fact, a DBI handle has some code refs in its bowels. n example would
be, for a DBI handle $h, $h->{HandleError}, a user-settable error
handler func.

Many complex objects (in Perl and otherwise) have such things, they are very
useful.

But there are more reasons not to stash a DBI in a session. Note that
you "freeze" this object in a process to be thawed in another. Some
languages support even the freezing of bits of code (with all their
context, wich isn't trivial!), to thaw them elsewhere -- but consider
for example the raw database handle, which at the lowest level is just a
file descriptor through which your app is talking to a database server:
this file handle has only meaning in the one application instance and in
the other it will be most probably a meaningless number (or worse: the
database server process will get very confused when two application
instances talk to it through the same open file descriptors).

The upshot is: *be very careful with what you put into a session stash*,
not everything will have the same meaning when you pull it out.

Sometimes (as in this case) some logic is in place to keep you from
shooting yourself in the foot. Lucky you ;-)

I'd recommend you read something up on Perl object oriented things. The
manual page perlootut is a good start. The Perl book (known as the Camel
Book) is a good read too. And Damian Conway's "Object Oriented Perl"
might find a place in your bookshelf too.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFE+R1kBcgs9XrR2kYRAms/AJ45Rn0KqnivWp6Z1NE4Nq0VIHp+FACeNtuU
vVLlxH+PX2sjuuG/Nsm8qVE=
=cyIW
-----END PGP SIGNATURE-----


Re: Request for Information

Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2006-09-01 at 16:35 -0400, dhaval gada wrote:

>   I am not using any references to subroutines in the session data. 

Maybe you're trying to store a DBI handle.

> And if some objects are implemented in Perl as references to
> subroutines, and
> some data structures include also subroutine references,
> then does it imply that no session management is possible with objects
> in embperl ???????????????

No!!!!!!!!!!!!

It means that you can't store references to subs or XS code.  Most
objects don't do that.

It's actually a pretty bad idea to put objects into a session.  You
should keep sessions as small as possible.  A good approach is to only
database keys, rather than the actual data.

- Perrin



Re: Request for Information

Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2006-09-01 at 16:35 -0400, dhaval gada wrote:

>   I am not using any references to subroutines in the session data. 

Maybe you're trying to store a DBI handle.

> And if some objects are implemented in Perl as references to
> subroutines, and
> some data structures include also subroutine references,
> then does it imply that no session management is possible with objects
> in embperl ???????????????

No!!!!!!!!!!!!

It means that you can't store references to subs or XS code.  Most
objects don't do that.

It's actually a pretty bad idea to put objects into a session.  You
should keep sessions as small as possible.  A good approach is to only
database keys, rather than the actual data.

- Perrin



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Request for Information

Posted by to...@tuxteam.de.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Sep 01, 2006 at 04:35:38PM -0400, dhaval gada wrote:
> Hi,
>  I am not using any references to subroutines in the session data.
> 
> And if some objects are implemented in Perl as references to subroutines,
> and
> some data structures include also subroutine references,
> then does it imply that no session management is possible with objects in
> embperl ???????????????

In fact, a DBI handle has some code refs in its bowels. n example would
be, for a DBI handle $h, $h->{HandleError}, a user-settable error
handler func.

Many complex objects (in Perl and otherwise) have such things, they are very
useful.

But there are more reasons not to stash a DBI in a session. Note that
you "freeze" this object in a process to be thawed in another. Some
languages support even the freezing of bits of code (with all their
context, wich isn't trivial!), to thaw them elsewhere -- but consider
for example the raw database handle, which at the lowest level is just a
file descriptor through which your app is talking to a database server:
this file handle has only meaning in the one application instance and in
the other it will be most probably a meaningless number (or worse: the
database server process will get very confused when two application
instances talk to it through the same open file descriptors).

The upshot is: *be very careful with what you put into a session stash*,
not everything will have the same meaning when you pull it out.

Sometimes (as in this case) some logic is in place to keep you from
shooting yourself in the foot. Lucky you ;-)

I'd recommend you read something up on Perl object oriented things. The
manual page perlootut is a good start. The Perl book (known as the Camel
Book) is a good read too. And Damian Conway's "Object Oriented Perl"
might find a place in your bookshelf too.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFE+R1kBcgs9XrR2kYRAms/AJ45Rn0KqnivWp6Z1NE4Nq0VIHp+FACeNtuU
vVLlxH+PX2sjuuG/Nsm8qVE=
=cyIW
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
Hi,
  I am not using any references to subroutines in the session data.

And if some objects are implemented in Perl as references to subroutines,
and
some data structures include also subroutine references,
then does it imply that no session management is possible with objects in
embperl ???????????????

Best Regards,
-Dhaval.


On 9/1/06, Gunnar Wolf <gw...@gwolf.org> wrote:
>
> dhaval gada dijo [Fri, Sep 01, 2006 at 09:14:37AM -0400]:
> > Hi,
> > I did try using %udat initially, but it throws the foll error:
> >
> > Can't store CODE items at blib/lib/Storable.pm (autosplit into
> > blib/lib/auto/Storable/_freeze.al) line 282, at
> >
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Serialize/Storable.pm
> > line 21
>
> Hi,
>
> Some objects are implemented in Perl as references to subroutines, and
> some data structures include also subroutine references. They cannot
> be serialized (this means, they cannot be converted into a
> representation able to be stored and brought back to life in a
> coherent state).
>
> In case you have such an object, instead of storing the object, store
> enough information to instantiate it whenever it is needed again.
>
> Greetings,
>
> --
> Gunnar Wolf - gwolf@gwolf.org - (+52-55)5623-0154 / 1451-2244
> PGP key 1024D/8BB527AF 2001-10-23
> Fingerprint: 0C79 D2D1 2C4E 9CE4 5973  F800 D80E F35A 8BB5 27AF
>

Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
Hi,
  I am not using any references to subroutines in the session data.

And if some objects are implemented in Perl as references to subroutines,
and
some data structures include also subroutine references,
then does it imply that no session management is possible with objects in
embperl ???????????????

Best Regards,
-Dhaval.


On 9/1/06, Gunnar Wolf <gw...@gwolf.org> wrote:
>
> dhaval gada dijo [Fri, Sep 01, 2006 at 09:14:37AM -0400]:
> > Hi,
> > I did try using %udat initially, but it throws the foll error:
> >
> > Can't store CODE items at blib/lib/Storable.pm (autosplit into
> > blib/lib/auto/Storable/_freeze.al) line 282, at
> >
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Serialize/Storable.pm
> > line 21
>
> Hi,
>
> Some objects are implemented in Perl as references to subroutines, and
> some data structures include also subroutine references. They cannot
> be serialized (this means, they cannot be converted into a
> representation able to be stored and brought back to life in a
> coherent state).
>
> In case you have such an object, instead of storing the object, store
> enough information to instantiate it whenever it is needed again.
>
> Greetings,
>
> --
> Gunnar Wolf - gwolf@gwolf.org - (+52-55)5623-0154 / 1451-2244
> PGP key 1024D/8BB527AF 2001-10-23
> Fingerprint: 0C79 D2D1 2C4E 9CE4 5973  F800 D80E F35A 8BB5 27AF
>

Re: Request for Information

Posted by Gunnar Wolf <gw...@gwolf.org>.
dhaval gada dijo [Fri, Sep 01, 2006 at 09:14:37AM -0400]:
> Hi,
> I did try using %udat initially, but it throws the foll error:
> 
> Can't store CODE items at blib/lib/Storable.pm (autosplit into
> blib/lib/auto/Storable/_freeze.al) line 282, at
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Serialize/Storable.pm
> line 21

Hi,

Some objects are implemented in Perl as references to subroutines, and
some data structures include also subroutine references. They cannot
be serialized (this means, they cannot be converted into a
representation able to be stored and brought back to life in a
coherent state).

In case you have such an object, instead of storing the object, store
enough information to instantiate it whenever it is needed again.

Greetings,

-- 
Gunnar Wolf - gwolf@gwolf.org - (+52-55)5623-0154 / 1451-2244
PGP key 1024D/8BB527AF 2001-10-23
Fingerprint: 0C79 D2D1 2C4E 9CE4 5973  F800 D80E F35A 8BB5 27AF

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Request for Information

Posted by Gerald Richter <ri...@ecos.de>.
Hi,
> I did try using %udat initially, but it throws the foll error:
>  
> Can't store CODE items at blib/lib/Storable.pm (autosplit 
> into blib/lib/auto/Storable/_freeze.al) line 282, at 
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Seriali
> ze/Storable.pm line 21 
> 
> 

That happens when you try to put a reference to a subroutine in the session
data (or an object that has a code ref into it). This will not work, neither
with Embperl nor with Apache::Session.

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


RE: Request for Information

Posted by Gerald Richter <ri...@ecos.de>.
Hi,
> I did try using %udat initially, but it throws the foll error:
>  
> Can't store CODE items at blib/lib/Storable.pm (autosplit 
> into blib/lib/auto/Storable/_freeze.al) line 282, at 
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Seriali
> ze/Storable.pm line 21 
> 
> 

That happens when you try to put a reference to a subroutine in the session
data (or an object that has a code ref into it). This will not work, neither
with Embperl nor with Apache::Session.

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
Hi,
I did try using %udat initially, but it throws the foll error:

Can't store CODE items at blib/lib/Storable.pm (autosplit into
blib/lib/auto/Storable/_freeze.al) line 282, at
/usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Serialize/Storable.pm
line 21


Thanks & Best Regards,
-Dhaval.


On 9/1/06, Gerald Richter <ri...@ecos.de> wrote:
>
>
> Hi,
>
> >   Well I did try printing the value for $cookie  and gives me
> > the foll value:
> >
> > EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > Also, while trying to retrieve the session, I tried supplying
> > the following values for $cookie:
> > 1) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > 2) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > 97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > 3) 97f3d8207d2e8d9afd7493ca28c3908a
> >
> > But, each time, I get the same error , i.e.
> > Died at
> > /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Generat
> > e/MD5.pm line 40.
> >
>
> As Perrin already wrote only the last one is a valid session id you can
> pass
> to tie.
>
> Anyway Embperl already handles session retrival for you and you only need
> to
> access the values in %udat to get your session data.
>
> If you really want to do it one your own you need to change the regex to
> extract the session id:
>
>      $cookie =~ /SESSION_ID=([a-z0-9]+)/;
>        $cookie = $1 ;
>
> Otherwise you have other cookie data in your session id which doesn't
> work.
>
> Gerald
>
>
>
> >
> >
> > Let me know what do you think. Is it an issue with cookie or
> > with retrieving sessions ?  Also, what value needs to be
> > supplied for $cookie while trying to retrieve a session.
> > tie %session, 'Apache::Session::File', $cookie,
> >
> > {  Directory => './tmp/sessions' ,
> >    LockDirectory => './var/lock/sessions' , };
> >
> >
> > Your help is really appreciated.
> >
> > Thanks & Best Regards,
> > Dhaval Gada.
> >
> > On 8/30/06, Perrin Harkins <pe...@elem.com> wrote:
> >
> >       [ Please keep replies on the mailing list ]
> >
> >       On Wed, 2006-08-30 at 09:29 -0400, dhaval gada wrote:
> >
> >       > If its the 1st time... then the following code. (i.e. session
> >       > creation)
> >       >
> >       > [-
> >       > eval   {
> >       >           tie %session, 'Apache::Session::File', undef,
> >       >             { Directory => './tmp/sessions',
> >       >               LockDirectory   => './var/lock/sessions',
> >       >             };
> >       >         };
> >       > if ($@)  {
> >       >             die "Global data is not accessible: $@";
> >       >            }
> >       >
> >       >        $session{"manpage"} = new BFM::ManPage();
> >       >        $session{"visit"} = '1 all';
> >       >        $tp = yes;
> >       >
> >       >        my $session_cookie =
> > "SESSION_ID=$session{_session_id};";
> >       >        $r->header_out("Set-Cookie" => $session_cookie);
> >       > -]
> >
> >       Okay, and you said that seemed to work.  I'd be nervous
> > about your use
> >       of relative directories in those path names, personally.
> >
> >       > And if not the 1st time... then the following
> > code.(i.e. retrieving
> >       > established session)
> >       > [-
> >       >       $r = Apache ->request;
> >       >       $cookie = $ r->header_in('Cookie');
> >       >       $ cookie =~ s/SESSION_ID=(\w*)/$1/;
> >       >
> >       >       eval {   tie %session ,
> > 'Apache::Session::File', $cookie,
> >       >                  {  Directory => './tmp/sessions',
> >       >                      LockDirectory => './var/lock/sessions',
> >       >                  };
> >       >              };
> >       >
> >       >        if ($@)
> >       >        {     die "Global data is not accessible: $@";  }
> >       > -]
> >
> >       And that's where it dies on you?  Have you checked the
> > value of $cookie
> >       inside that eval?  Maybe it isn't what you think it is.
> >
> >       - Perrin
> >
> >
> >
> >
> >
>
>
>
> ** Virus checked by BB-5000 Mailfilter **
>
>

Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
Hi,
I did try using %udat initially, but it throws the foll error:

Can't store CODE items at blib/lib/Storable.pm (autosplit into
blib/lib/auto/Storable/_freeze.al) line 282, at
/usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Serialize/Storable.pm
line 21


Thanks & Best Regards,
-Dhaval.


On 9/1/06, Gerald Richter <ri...@ecos.de> wrote:
>
>
> Hi,
>
> >   Well I did try printing the value for $cookie  and gives me
> > the foll value:
> >
> > EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > Also, while trying to retrieve the session, I tried supplying
> > the following values for $cookie:
> > 1) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > 2) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > 97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > 3) 97f3d8207d2e8d9afd7493ca28c3908a
> >
> > But, each time, I get the same error , i.e.
> > Died at
> > /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Generat
> > e/MD5.pm line 40.
> >
>
> As Perrin already wrote only the last one is a valid session id you can
> pass
> to tie.
>
> Anyway Embperl already handles session retrival for you and you only need
> to
> access the values in %udat to get your session data.
>
> If you really want to do it one your own you need to change the regex to
> extract the session id:
>
>      $cookie =~ /SESSION_ID=([a-z0-9]+)/;
>        $cookie = $1 ;
>
> Otherwise you have other cookie data in your session id which doesn't
> work.
>
> Gerald
>
>
>
> >
> >
> > Let me know what do you think. Is it an issue with cookie or
> > with retrieving sessions ?  Also, what value needs to be
> > supplied for $cookie while trying to retrieve a session.
> > tie %session, 'Apache::Session::File', $cookie,
> >
> > {  Directory => './tmp/sessions' ,
> >    LockDirectory => './var/lock/sessions' , };
> >
> >
> > Your help is really appreciated.
> >
> > Thanks & Best Regards,
> > Dhaval Gada.
> >
> > On 8/30/06, Perrin Harkins <pe...@elem.com> wrote:
> >
> >       [ Please keep replies on the mailing list ]
> >
> >       On Wed, 2006-08-30 at 09:29 -0400, dhaval gada wrote:
> >
> >       > If its the 1st time... then the following code. (i.e. session
> >       > creation)
> >       >
> >       > [-
> >       > eval   {
> >       >           tie %session, 'Apache::Session::File', undef,
> >       >             { Directory => './tmp/sessions',
> >       >               LockDirectory   => './var/lock/sessions',
> >       >             };
> >       >         };
> >       > if ($@)  {
> >       >             die "Global data is not accessible: $@";
> >       >            }
> >       >
> >       >        $session{"manpage"} = new BFM::ManPage();
> >       >        $session{"visit"} = '1 all';
> >       >        $tp = yes;
> >       >
> >       >        my $session_cookie =
> > "SESSION_ID=$session{_session_id};";
> >       >        $r->header_out("Set-Cookie" => $session_cookie);
> >       > -]
> >
> >       Okay, and you said that seemed to work.  I'd be nervous
> > about your use
> >       of relative directories in those path names, personally.
> >
> >       > And if not the 1st time... then the following
> > code.(i.e. retrieving
> >       > established session)
> >       > [-
> >       >       $r = Apache ->request;
> >       >       $cookie = $ r->header_in('Cookie');
> >       >       $ cookie =~ s/SESSION_ID=(\w*)/$1/;
> >       >
> >       >       eval {   tie %session ,
> > 'Apache::Session::File', $cookie,
> >       >                  {  Directory => './tmp/sessions',
> >       >                      LockDirectory => './var/lock/sessions',
> >       >                  };
> >       >              };
> >       >
> >       >        if ($@)
> >       >        {     die "Global data is not accessible: $@";  }
> >       > -]
> >
> >       And that's where it dies on you?  Have you checked the
> > value of $cookie
> >       inside that eval?  Maybe it isn't what you think it is.
> >
> >       - Perrin
> >
> >
> >
> >
> >
>
>
>
> ** Virus checked by BB-5000 Mailfilter **
>
>

Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
Hi,
  My apologies. I did remove the leading/trailing spaces and it does'n't
throw any errors now. However, I cannot retrieve the stored data.

For eg:  I store $session{"visit"} = 1   when creating the session. However,
when I retrieve the session and try to print the value of
$session{"visit"}  it returns nothing.

  Storing a scalar value in %session is just for testing purpose. I intend
to store objects for my web application.

What could be the reason ???

Thanks & Best Regards,
Dhaval Gada.



On 8/31/06, Jonathan Vanasco <mo...@2xlp.com> wrote:
>
>
> On Aug 31, 2006, at 3:24 PM, dhaval gada wrote:
>
>
> > I checked the files created in the /tmp/sessions  directory. When I
> > tried to view the contents of the file named
> > "f92c58deb6047b12470d51f6e1767e8f ", using the vi editor, it gave
> > me the following message:
>
> On Aug 31, 2006, at 3:06 PM, Perrin Harkins wrote:
> > Did you look at line 40 to see what it does?  It's failing to validate
> > the session ID you passed in.  You might have some extra junk
> > characters
> > in there, like a line break at the end.
>
> Did you follow perrin's advice and strip leading/trailing whitespace?
>
>

Re: Request for Information

Posted by Jonathan Vanasco <mo...@2xlp.com>.
On Aug 31, 2006, at 3:24 PM, dhaval gada wrote:


> I checked the files created in the /tmp/sessions  directory. When I  
> tried to view the contents of the file named  
> "f92c58deb6047b12470d51f6e1767e8f ", using the vi editor, it gave  
> me the following message:

On Aug 31, 2006, at 3:06 PM, Perrin Harkins wrote:
> Did you look at line 40 to see what it does?  It's failing to validate
> the session ID you passed in.  You might have some extra junk  
> characters
> in there, like a line break at the end.

Did you follow perrin's advice and strip leading/trailing whitespace?


Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
Hi,

I checked the files created in the /tmp/sessions  directory. When I tried to
view the contents of the file named "f92c58deb6047b12470d51f6e1767e8f ",
using the vi editor, it gave me the following message:


"f92c58deb6047b12470d51f6e1767e8f" [Incomplete last line] 2 lines, 56
character
s (6 null)
[Hit return to continue]

And when I press the ENTER key, it shows the foll:

^E^F^C^A
 f92c58deb6047b12470d51f6e1767e8f^K_session_id


 I get the errors only while retrieving the session. May be the session is
never created and it does'n't give any error as well. If thats the case, how
do I check whether a new session is created or not and if it is then is it
stored correctly in the files or not?

Will await your reply on this,

Thanks & Best Regards,
Dhaval Gada.


On 8/31/06, Perrin Harkins <pe...@elem.com> wrote:
>
> On Thu, 2006-08-31 at 12:37 -0400, dhaval gada wrote:
> >
> > Hi,
> >   Well I did try printing the value for $cookie  and gives me the foll
> > value:
> >
> > EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
>
> That's not a session ID.
>
> > Also, while trying to retrieve the session, I tried supplying the
> > following values for $cookie:
> > 1) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > 2) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> > 97f3d8207d2e8d9afd7493ca28c3908a;
> > BIGipServerwebster2=593498284.20480.0000
> >
> > 3) 97f3d8207d2e8d9afd7493ca28c3908a
>
> That last one looks like a session ID.  That's what you should be
> passing in.
>
> > But, each time, I get the same error , i.e.
> > Died
> > at
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Generate/MD5.pm line
> 40.
>
> Did you look at line 40 to see what it does?  It's failing to validate
> the session ID you passed in.  You might have some extra junk characters
> in there, like a line break at the end.
>
> - Perrin
>
>

Re: Request for Information

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2006-08-31 at 12:37 -0400, dhaval gada wrote:
> 
> Hi,
>   Well I did try printing the value for $cookie  and gives me the foll
> value:
>  
> EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> BIGipServerwebster2=593498284.20480.0000 

That's not a session ID.

> Also, while trying to retrieve the session, I tried supplying the
> following values for $cookie:
> 1) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a;
> BIGipServerwebster2=593498284.20480.0000 
>  
> 2) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
> 97f3d8207d2e8d9afd7493ca28c3908a;
> BIGipServerwebster2=593498284.20480.0000 
>  
> 3) 97f3d8207d2e8d9afd7493ca28c3908a

That last one looks like a session ID.  That's what you should be
passing in.

> But, each time, I get the same error , i.e. 
> Died
> at /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Generate/MD5.pm line 40.

Did you look at line 40 to see what it does?  It's failing to validate
the session ID you passed in.  You might have some extra junk characters
in there, like a line break at the end.

- Perrin


RE: Request for Information

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>   Well I did try printing the value for $cookie  and gives me 
> the foll value:
>  
> EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6; 
> SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a; 
> BIGipServerwebster2=593498284.20480.0000 
>  
> Also, while trying to retrieve the session, I tried supplying 
> the following values for $cookie:
> 1) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6; 
> SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a; 
> BIGipServerwebster2=593498284.20480.0000 
>  
> 2) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6; 
> 97f3d8207d2e8d9afd7493ca28c3908a; 
> BIGipServerwebster2=593498284.20480.0000 
>  
> 3) 97f3d8207d2e8d9afd7493ca28c3908a
>  
> But, each time, I get the same error , i.e. 
> Died at 
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Generat
> e/MD5.pm line 40.
> 

As Perrin already wrote only the last one is a valid session id you can pass
to tie.

Anyway Embperl already handles session retrival for you and you only need to
access the values in %udat to get your session data.

If you really want to do it one your own you need to change the regex to
extract the session id:

      $cookie =~ /SESSION_ID=([a-z0-9]+)/;
	$cookie = $1 ;

Otherwise you have other cookie data in your session id which doesn't work. 

Gerald



>  
> 
> Let me know what do you think. Is it an issue with cookie or 
> with retrieving sessions ?  Also, what value needs to be 
> supplied for $cookie while trying to retrieve a session.
> tie %session, 'Apache::Session::File', $cookie,
> 
> {  Directory => './tmp/sessions' ,
>    LockDirectory => './var/lock/sessions' , };
>  
>  
> Your help is really appreciated.
>  
> Thanks & Best Regards,
> Dhaval Gada.
> 
> On 8/30/06, Perrin Harkins <pe...@elem.com> wrote: 
> 
> 	[ Please keep replies on the mailing list ]
> 	
> 	On Wed, 2006-08-30 at 09:29 -0400, dhaval gada wrote:
> 	
> 	> If its the 1st time... then the following code. (i.e. session
> 	> creation)
> 	>
> 	> [-
> 	> eval   {
> 	>           tie %session, 'Apache::Session::File', undef,
> 	>             { Directory => './tmp/sessions', 
> 	>               LockDirectory   => './var/lock/sessions',
> 	>             };
> 	>         };
> 	> if ($@)  {
> 	>             die "Global data is not accessible: $@";
> 	>            }
> 	>
> 	>        $session{"manpage"} = new BFM::ManPage();
> 	>        $session{"visit"} = '1 all';
> 	>        $tp = yes;
> 	>
> 	>        my $session_cookie = 
> "SESSION_ID=$session{_session_id};"; 
> 	>        $r->header_out("Set-Cookie" => $session_cookie);
> 	> -]
> 	
> 	Okay, and you said that seemed to work.  I'd be nervous 
> about your use
> 	of relative directories in those path names, personally. 
> 	
> 	> And if not the 1st time... then the following 
> code.(i.e. retrieving
> 	> established session)
> 	> [-
> 	>       $r = Apache ->request;
> 	>       $cookie = $ r->header_in('Cookie');
> 	>       $ cookie =~ s/SESSION_ID=(\w*)/$1/; 
> 	>
> 	>       eval {   tie %session , 
> 'Apache::Session::File', $cookie,
> 	>                  {  Directory => './tmp/sessions',
> 	>                      LockDirectory => './var/lock/sessions',
> 	>                  }; 
> 	>              };
> 	>
> 	>        if ($@)
> 	>        {     die "Global data is not accessible: $@";  }
> 	> -]
> 	
> 	And that's where it dies on you?  Have you checked the 
> value of $cookie
> 	inside that eval?  Maybe it isn't what you think it is.
> 	
> 	- Perrin
> 	
> 	
> 
> 
> 


 
** Virus checked by BB-5000 Mailfilter ** 


RE: Request for Information

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>   Well I did try printing the value for $cookie  and gives me 
> the foll value:
>  
> EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6; 
> SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a; 
> BIGipServerwebster2=593498284.20480.0000 
>  
> Also, while trying to retrieve the session, I tried supplying 
> the following values for $cookie:
> 1) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6; 
> SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a; 
> BIGipServerwebster2=593498284.20480.0000 
>  
> 2) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6; 
> 97f3d8207d2e8d9afd7493ca28c3908a; 
> BIGipServerwebster2=593498284.20480.0000 
>  
> 3) 97f3d8207d2e8d9afd7493ca28c3908a
>  
> But, each time, I get the same error , i.e. 
> Died at 
> /usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Generat
> e/MD5.pm line 40.
> 

As Perrin already wrote only the last one is a valid session id you can pass
to tie.

Anyway Embperl already handles session retrival for you and you only need to
access the values in %udat to get your session data.

If you really want to do it one your own you need to change the regex to
extract the session id:

      $cookie =~ /SESSION_ID=([a-z0-9]+)/;
	$cookie = $1 ;

Otherwise you have other cookie data in your session id which doesn't work. 

Gerald



>  
> 
> Let me know what do you think. Is it an issue with cookie or 
> with retrieving sessions ?  Also, what value needs to be 
> supplied for $cookie while trying to retrieve a session.
> tie %session, 'Apache::Session::File', $cookie,
> 
> {  Directory => './tmp/sessions' ,
>    LockDirectory => './var/lock/sessions' , };
>  
>  
> Your help is really appreciated.
>  
> Thanks & Best Regards,
> Dhaval Gada.
> 
> On 8/30/06, Perrin Harkins <pe...@elem.com> wrote: 
> 
> 	[ Please keep replies on the mailing list ]
> 	
> 	On Wed, 2006-08-30 at 09:29 -0400, dhaval gada wrote:
> 	
> 	> If its the 1st time... then the following code. (i.e. session
> 	> creation)
> 	>
> 	> [-
> 	> eval   {
> 	>           tie %session, 'Apache::Session::File', undef,
> 	>             { Directory => './tmp/sessions', 
> 	>               LockDirectory   => './var/lock/sessions',
> 	>             };
> 	>         };
> 	> if ($@)  {
> 	>             die "Global data is not accessible: $@";
> 	>            }
> 	>
> 	>        $session{"manpage"} = new BFM::ManPage();
> 	>        $session{"visit"} = '1 all';
> 	>        $tp = yes;
> 	>
> 	>        my $session_cookie = 
> "SESSION_ID=$session{_session_id};"; 
> 	>        $r->header_out("Set-Cookie" => $session_cookie);
> 	> -]
> 	
> 	Okay, and you said that seemed to work.  I'd be nervous 
> about your use
> 	of relative directories in those path names, personally. 
> 	
> 	> And if not the 1st time... then the following 
> code.(i.e. retrieving
> 	> established session)
> 	> [-
> 	>       $r = Apache ->request;
> 	>       $cookie = $ r->header_in('Cookie');
> 	>       $ cookie =~ s/SESSION_ID=(\w*)/$1/; 
> 	>
> 	>       eval {   tie %session , 
> 'Apache::Session::File', $cookie,
> 	>                  {  Directory => './tmp/sessions',
> 	>                      LockDirectory => './var/lock/sessions',
> 	>                  }; 
> 	>              };
> 	>
> 	>        if ($@)
> 	>        {     die "Global data is not accessible: $@";  }
> 	> -]
> 	
> 	And that's where it dies on you?  Have you checked the 
> value of $cookie
> 	inside that eval?  Maybe it isn't what you think it is.
> 	
> 	- Perrin
> 	
> 	
> 
> 
> 


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
 Hi,
  Well I did try printing the value for $cookie  and gives me the foll
value:

EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a; BIGipServerwebster2=
593498284.20480.0000

Also, while trying to retrieve the session, I tried supplying the following
values for $cookie:
1) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
SESSION_ID=97f3d8207d2e8d9afd7493ca28c3908a; BIGipServerwebster2=
593498284.20480.0000

2) EMBPERL_UID=df9c7b02f04343807ef7ab570ab43dc6;
97f3d8207d2e8d9afd7493ca28c3908a; BIGipServerwebster2=593498284.20480.0000

3) 97f3d8207d2e8d9afd7493ca28c3908a

But, each time, I get the same error , i.e.
*Died at
/usr/local/ext/perl/5.8.0/lib/site_perl/Apache/Session/Generate/MD5.pm line
40.*

**
Let me know what do you think. Is it an issue with cookie or with retrieving
sessions ?  Also, what value needs to be supplied for $cookie while trying
to retrieve a session.
tie %session, 'Apache::Session::File', $cookie,

{  Directory => './tmp/sessions',
   LockDirectory => './var/lock/sessions' ,
};


Your help is really appreciated.

Thanks & Best Regards,
Dhaval Gada.

On 8/30/06, Perrin Harkins <pe...@elem.com> wrote:
>
> [ Please keep replies on the mailing list ]
>
> On Wed, 2006-08-30 at 09:29 -0400, dhaval gada wrote:
>
> > If its the 1st time... then the following code. (i.e. session
> > creation)
> >
> > [-
> > eval   {
> >           tie %session, 'Apache::Session::File', undef,
> >             { Directory => './tmp/sessions',
> >               LockDirectory   => './var/lock/sessions',
> >             };
> >         };
> > if ($@)  {
> >             die "Global data is not accessible: $@";
> >            }
> >
> >        $session{"manpage"} = new BFM::ManPage();
> >        $session{"visit"} = '1 all';
> >        $tp = yes;
> >
> >        my $session_cookie = "SESSION_ID=$session{_session_id};";
> >        $r->header_out("Set-Cookie" => $session_cookie);
> > -]
>
> Okay, and you said that seemed to work.  I'd be nervous about your use
> of relative directories in those path names, personally.
>
> > And if not the 1st time... then the following code.(i.e. retrieving
> > established session)
> > [-
> >       $r = Apache ->request;
> >       $cookie = $ r->header_in('Cookie');
> >       $ cookie =~ s/SESSION_ID=(\w*)/$1/;
> >
> >       eval {   tie %session , 'Apache::Session::File', $cookie,
> >                  {  Directory => './tmp/sessions',
> >                      LockDirectory => './var/lock/sessions',
> >                  };
> >              };
> >
> >        if ($@)
> >        {     die "Global data is not accessible: $@";  }
> > -]
>
> And that's where it dies on you?  Have you checked the value of $cookie
> inside that eval?  Maybe it isn't what you think it is.
>
> - Perrin
>
>

Re: Request for Information

Posted by Jonathan Vanasco <mo...@2xlp.com>.
On Aug 30, 2006, at 4:03 PM, Perrin Harkins wrote:

>>        my $session_cookie = "SESSION_ID=$session{_session_id};";
>>        $r->header_out("Set-Cookie" => $session_cookie);

Does that even create a valid cookie?

Cookies have expiration dates , paths, and domains



>>       $cookie = $ r->header_in('Cookie');
>>       $ cookie =~ s/SESSION_ID=(\w*)/$1/;
> And that's where it dies on you?  Have you checked the value of  
> $cookie
> inside that eval?  Maybe it isn't what you think it is.

you can have an arrray of  cookies with the same name.

this is from my own library,  which does extensive session management.

it might confuse you, but at the same time maybe it'll help you a bit:


as background:
	$self is per-request context object with some refs to ApacheRequest  
and some other  variables.
		most objects in my app are given this ctx object,
	CookieDefaults is a constant in the context object (or subclass)  
that has all of the configuration options
	ApacheSessionStore is a constant in the context object (or subclass)  
that names the Apache::Session backend
	ApacheSessionOptions is a hashref with the options
		ApacheSessionOptions{ ApacheSessionStore }= { options }

	to set a cookie, i call __cookie__session__set

	to pull the session info, i divine the session id
	in this case __divine_session_id__cookie
		__divine_session_id__cookie reads in all of the cookies, looks for  
the session ( named in cookie defaults ), and if it finds one,  
validates it ( checks for length, then tries to tie it )




--------

sub __cookie__session__set {
	my 	( $self )= @_;
	$self->__cookie_baker(
		$self->CookieDefaults->{'names'}{'Session'},
		$self->{'__SESSION'}{_session_id},
		$self->CookieDefaults->{'expires'},
		$self->CookieDefaults->{'secure'}
	);
}

sub __divine_session_id__cookie
{
	my	( $self )= @_;
	my 	$sessionID;

	#	Read In All The Cookies We Can
	eval {
		my 	$cookiejar= Apache2::Cookie::Jar->new( $self->{'ApacheRequest'} );
		if ( $cookiejar->cookies( $self->CookieDefaults->{'names'} 
{'Session'} ) ) {
			my 	%c_cookies= Apache2::Cookie->fetch( $self->{'ApacheRequest'} );
			my 	$c_value= $c_cookies{ $self->CookieDefaults->{'names'} 
{'Session'} }->value;
			$sessionID= $self->__session__validate( $c_value );
		}
	};
	if ( $@ ) {
		print STDERR "\nERROR - can not parse cookie";
	}
	return $sessionID;
}


sub __cookie_baker
{
	my 	( $self , $name , $value , $expiry , $secure )= @_;
	foreach my $domain (@{$self->CookieDefaults->{'domain'}}) {
		my	$cookie= Apache2::Cookie->new(
			$self->{'ApacheRequestRec'},
			-name 		=> $name   ,
			-value 		=> $value  ,
			-expires 	=> $expiry ,
			-secure 	=> $secure ,
		);
			$cookie->path( $self->CookieDefaults->{'path'} );
			$cookie->domain( $domain );
		$self->{'ApacheRequestRec'}->err_headers_out->add('Set-Cookie'=>  
$cookie);
	}
}

sub __session__validate {
	my	( $self , $sessionID )= @_;

	# 	If not 32 chars long, kill it
   	if ( length($sessionID) != 32 ) {
   		$sessionID= undef;
   	}

	if ( $sessionID ) {
		$sessionID= $self->__session__tie( $sessionID );
	}
	return $sessionID;
}

sub __session__tie {
	my	( $self , $sessionID )= @_;
	my 	$error;
	my 	%session;
	my 	$store= $self->ApacheSessionStore ;
	my 	$options= $self->ApacheSessionOptions->{ $store };

	# this is a block not an eval, because we want to use error codes
	{
		no strict 'refs'; # this gets by the generate a new id stuff
		if 	( $store eq 'File' ) {
			eval { tie %session , 'Apache::Session::File', $sessionID,  
$options } ;
			if ( $@ ) {
				$error= 1;
				$sessionID= undef;
			}
		}
		else {
			# unsupported mode in ApacheSessionStore
			$error= 1;
			$sessionID= undef;
		}
	}
	if ( $error ) {
		return 0;
	}
	$self->{'__SESSION'}= \%session;
	return $self->{'__SESSION'}{_session_id};
}




// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -



Re: Request for Information

Posted by Perrin Harkins <pe...@elem.com>.
[ Please keep replies on the mailing list ]

On Wed, 2006-08-30 at 09:29 -0400, dhaval gada wrote:

> If its the 1st time... then the following code. (i.e. session
> creation)
> 
> [-    
> eval   {
>           tie %session, 'Apache::Session::File', undef,
>             { Directory => './tmp/sessions', 
>               LockDirectory   => './var/lock/sessions',
>             };
>         };
> if ($@)  {
>             die "Global data is not accessible: $@";
>            }
> 
>        $session{"manpage"} = new BFM::ManPage(); 
>        $session{"visit"} = '1 all';
>        $tp = yes;
>        
>        my $session_cookie = "SESSION_ID=$session{_session_id};";
>        $r->header_out("Set-Cookie" => $session_cookie); 
> -]

Okay, and you said that seemed to work.  I'd be nervous about your use
of relative directories in those path names, personally.

> And if not the 1st time... then the following code.(i.e. retrieving
> established session)
> [-
>       $r = Apache ->request;
>       $cookie = $ r->header_in('Cookie');
>       $ cookie =~ s/SESSION_ID=(\w*)/$1/;
> 
>       eval {   tie %session , 'Apache::Session::File', $cookie,
>                  {  Directory => './tmp/sessions',
>                      LockDirectory => './var/lock/sessions',
>                  };
>              };
> 
>        if ($@) 
>        {     die "Global data is not accessible: $@";  }
> -]

And that's where it dies on you?  Have you checked the value of $cookie
inside that eval?  Maybe it isn't what you think it is.

- Perrin


Re: Request for Information

Posted by Perrin Harkins <pe...@elem.com>.
On Tue, 2006-08-29 at 14:45 -0400, dhaval gada wrote:
>    I did try the Embperl site, but could'n't find anything there.

Did you try the Embperl mailing list?

> Also, I believe is it more to do with the Apache::Session module.

There is no code in Apache::Session that generates that error message.
It's either your own code generating it, or code in Embperl.

> I am able to create a new cookie when the session is started for the
> 1st time, but it fails and gives the error mesg when it  either tries
> to read the cookie file or when it tries to retireve the desired
> object from the file by making use of the retrieved session ID from
> the cookie file.

Is this your code that is trying to load the session?  If so, show it to
us.

> Has it to do anything with apache server like any specific settings
> required or etc.

I'd say that's very unlikely.

- Perrin


Re: Request for Information

Posted by dhaval gada <dh...@gmail.com>.
Hi Perrin,
   I did try the Embperl site, but could'n't find anything there.
Also, I believe is it more to do with the Apache::Session module.

I am able to create a new cookie when the session is started for the
1st time, but it fails and gives the error mesg when it  either tries
to read the cookie file or when it tries to retireve the desired
object from the file by making use of the retrieved session ID from
the cookie file.

Has it to do anything with apache server like any specific settings
required or etc.

I appreciate your ready response and I am hoping to reach a solution
to this asap.
Thankyou.

Thanks & Best Regards,
Dhaval Gada.



On 8/29/06, Perrin Harkins <pe...@elem.com> wrote:
> On Tue, 2006-08-29 at 13:35 -0400, dhaval gada wrote:
> > [1989]ERR: 24: Error in Perl code: Global data is not accessible: Died
> > at /usr/local/lib/site_perl/Apache/Session/Generate/MD5.pm line 40.
> >
> > Atari 800 HTML::Embperl 1.3.6 [Fri Aug 25 11:18:35 2006]
>
> If you're really running on an Atari 800, I'm impressed.  I think
> mod_perl runs best with the Donkey Kong cartridge :)
>
> I've never seen an error like this before, but Embperl has its own site
> and mailing list where you might have better luck getting help with
> this:
> http://perl.apache.org/embperl/
>
> - Perrin
>
>

Re: Request for Information

Posted by Perrin Harkins <pe...@elem.com>.
On Tue, 2006-08-29 at 13:35 -0400, dhaval gada wrote:
> [1989]ERR: 24: Error in Perl code: Global data is not accessible: Died
> at /usr/local/lib/site_perl/Apache/Session/Generate/MD5.pm line 40.
> 
> Atari 800 HTML::Embperl 1.3.6 [Fri Aug 25 11:18:35 2006]

If you're really running on an Atari 800, I'm impressed.  I think
mod_perl runs best with the Donkey Kong cartridge :)

I've never seen an error like this before, but Embperl has its own site
and mailing list where you might have better luck getting help with
this:
http://perl.apache.org/embperl/

- Perrin