Re: Apache::Session and pnotes

2003-09-05 Thread Enrico Sorcinelli
On Tue, 2 Sep 2003 20:21:45 +0200
Xavier Noria [EMAIL PROTECTED] wrote:

 On Tuesday 02 September 2003 07:28, Perrin Harkins wrote:
 
  Sorry, I don't understand what you're saying here.  What you should
  be doing is fetching the session once, putting it in pnotes, and
  getting it from pnotes for the rest of the request.
 
 I am sorry, I'll try to reword it.
 
 Let's assume a new user comes to the website. We set up a session for 
 him and put the session id in a cookie to be sent in the response. As 
 you know, somewhere in the request cycle of that particular request 
 Apache::Session::Oracle stores the session in the database.
 
 When later that very user comes back to the website with a valid session 
 id in the cookie, one reads the session from the database.
 
 The problem I am facing is that if the session is stored in pnotes() it 
 doesn't end up in the database. When the user comes back that id 
 corresponds to no row in the sessions table.
 

Hi Xavier,

If you want a transaparent session management you could also look 
Apache::SessionManager
mod_perl extension. No extra code to write but a few lines to add in httpd.conf or
.htaccess.file

:-)

by

- Enrico


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: Apache::Session and pnotes

2003-09-05 Thread Perrin Harkins
Sorry, I missed this message until now...

On Tue, 2003-09-02 at 14:21, Xavier Noria wrote:
 Let's assume a new user comes to the website. We set up a session for 
 him and put the session id in a cookie to be sent in the response. As 
 you know, somewhere in the request cycle of that particular request 
 Apache::Session::Oracle stores the session in the database.

It happens when the session object gets destroyed.

 The problem I am facing is that if the session is stored in pnotes() it 
 doesn't end up in the database. When the user comes back that id 
 corresponds to no row in the sessions table.

Okay, the problem is not pnotes.  The pnotes stuff gets cleared at the
end of every request, so it would save then, after the user
disconnects.  Probably what's happening is that you have a scoping
problem somewhere in your code that deals with pnotes and it is keeping
the session object from going out of scope.

One thing you can try is explicitly saving the session, using the method
described in the Apache::Session documentation.  If that works, it means
you just have to find your scoping problem.  Maybe you can locate it by
removing code bit by bit until the problem goes away.  If you can make a
very short script that demonstrates the problem, you can post it here
and we'll help you find it.

- Perrin


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: Apache::Session and pnotes

2003-09-02 Thread Perrin Harkins
Xavier Noria wrote:
It seems, however, that Apache::Session objects stop being stored when I 
put the session in pnotes() with a code analogous to this:
Can you tell us more about the problem is?  What do you see when you 
take the session hash back out of pnotes?

my $r = Apache::Request-instance(shift);
No need to involve Apache::Request just for this.  Your handler should 
be getting $r passed to it.

tie my (%session), 'Apache::Session::Oracle', undef,
  {Handle = $class-dbh(), Commit = 1};

$r-pnotes(session = \%session);
Show us the code you use to get it back.

- Perrin



--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: Apache::Session and pnotes

2003-09-02 Thread Xavier Noria
On Tuesday 02 September 2003 07:46, you wrote:

(I am sorry I am not replying to the actual email, but to a forwarded 
copy from my desktop at home.)

  It seems, however, that Apache::Session objects stop being stored
  when I put the session in pnotes() with a code analogous to this:

 Can you tell us more about the problem is?  What do you see when you
 take the session hash back out of pnotes?

I have dumped the hash in a content handler and it seems to be OK.

  my $r = Apache::Request-instance(shift);

 No need to involve Apache::Request just for this.  Your handler
 should be getting $r passed to it.

Apache::Request is used because the authenticator handles login via 
param(), and more handlers need the parameters afterwards. 

  tie my (%session), 'Apache::Session::Oracle', undef,
{Handle = $class-dbh(), Commit = 1};
 
  $r-pnotes(session = \%session);

 Show us the code you use to get it back.

When a request is received the session id is retrieved from a cookie. 
The schema (with some irrelevant checks removed) would be this:

my %cookies = Apache::Cookie-fetch;
my $cookie = $cookies{COOKIE_NAME()};
my $session_id = $cookie-value;
my %session;
eval {
tie %session, 'Apache::Session::Oracle', $session_id,
  {Handle = $class-dbh(), Commit = 1};
};

The eval block is there now because it seems Apache::Session::Oracle 
dies if it cannot retrieve the session.

That code works all right if \%session is not stored in pnotes(), but if 
it is put the session is not read back from the database and I have 
checked from a database client that there is no new row written.

I am doing basic stuff with this, so if it sounds strange it is likely 
that I doing something wrong.

-- fxn



-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: Apache::Session and pnotes

2003-09-02 Thread Perrin Harkins
On Tue, 2003-09-02 at 05:02, Xavier Noria wrote:
  Can you tell us more about the problem is?  What do you see when you
  take the session hash back out of pnotes?
 
 I have dumped the hash in a content handler and it seems to be OK.

Okay, then what is the problem that you're asking for help with here?

 When a request is received the session id is retrieved from a cookie. 
 The schema (with some irrelevant checks removed) would be this:
 
 my %cookies = Apache::Cookie-fetch;
 my $cookie = $cookies{COOKIE_NAME()};
 my $session_id = $cookie-value;
 my %session;
 eval {
 tie %session, 'Apache::Session::Oracle', $session_id,
   {Handle = $class-dbh(), Commit = 1};
 };

Okay, but I was asking how you get it back from pnotes.

 That code works all right if \%session is not stored in pnotes(), but if 
 it is put the session is not read back from the database and I have 
 checked from a database client that there is no new row written.

Sorry, I don't understand what you're saying here.  What you should be
doing is fetching the session once, putting it in pnotes, and getting it
from pnotes for the rest of the request.

- Perrin


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: Apache::Session and pnotes

2003-09-02 Thread Xavier Noria
On Tuesday 02 September 2003 07:28, Perrin Harkins wrote:

 Sorry, I don't understand what you're saying here.  What you should
 be doing is fetching the session once, putting it in pnotes, and
 getting it from pnotes for the rest of the request.

I am sorry, I'll try to reword it.

Let's assume a new user comes to the website. We set up a session for 
him and put the session id in a cookie to be sent in the response. As 
you know, somewhere in the request cycle of that particular request 
Apache::Session::Oracle stores the session in the database.

When later that very user comes back to the website with a valid session 
id in the cookie, one reads the session from the database.

The problem I am facing is that if the session is stored in pnotes() it 
doesn't end up in the database. When the user comes back that id 
corresponds to no row in the sessions table.

Is it better now?

-- fxn




-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html