You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by "D. L. Fox" <df...@netpath.net> on 2003/09/02 04:40:49 UTC

Session->Abandon question

Can $Session->Abandon be called from an include file, even if
$Response->TrapInclude is used?  Does the user have to navigate (or be
redirected) to another page for it to "take effect"?

Although I have been using Apache-ASP for some time, I am new to using the
Session object.  I started playing with it at home on my win98SE machine.
I'm using Apache 1.3.27, Perl 5.6.1 built for MSWin32-x86-multi-thread
(ActiveState), mod_perl is listed as 1.28 on the perl.apache.org site,
although it shows 1.27_01-dev when viewing the output of %ENV.

I'm not sure the specific version of Apache::ASP being used but all the
above, including Apache-ASP, came bundled with the mod_perl 1.28 Windows
binary currently being distributed at the perl.apache.org site.

The problem I ran into was when using $Session->Abandon from inside an
include file.  The data I stored in the Session did not disappear.  However,
when I "hit" a regular ASP page calling $Session->Abandon, it works like a
charm.

I did a "workaround", although I don't know if it's a Good Thing to do, or
the Right Thing to do.

foreach my $skey(keys(%{$Session})) {
    $Session->{$skey} = undef;
}


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


Re: Session->Abandon question

Posted by "D. L. Fox" <df...@netpath.net>.
----- Original Message -----
From: "Josh Chamas" <jo...@chamas.com>
To: "D. L. Fox" <df...@netpath.net>
Cc: <as...@perl.apache.org>
Sent: Thursday, September 04, 2003 1:07 AM
Subject: Re: Session->Abandon question

> I haven't reimplemnted something for fun for quite a while,
> perhaps I have gotten too jaded, and I found sentiment inspiring :)
> Don't worry, I won't reimplement Apache::ASP from scratch, I'll
> take my inspiration out on something else!

whew ...::::wiping sweat::::... glad to hear that.......hehe

Actually, I wanted to take the time to thank you, and whomever has helped,
for developing Apache-ASP.  I had programmed in Perl for some time (though I
don't claim to be good at it :) but, since I also knew VB, I had switched to
VB in IIS-ASP for web stuff because of its ease of use in embedding code
with HTML (please don't beat me too severely).  When I discovered
Apache-ASP, it was like a dream come true.  I would much rather code in Perl
than any other language.  Thanks for such a fine product!


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


Re: Session->Abandon question

Posted by Josh Chamas <jo...@chamas.com>.
D. L. Fox wrote:
 > ...
> I have been re-writing much of what I had anyway.  I find myself doing this
> alot whenever I take on a new project.  It seems when I almost complete
> working on something new, an idea about a different way of doing it comes to
> me, and I realize I could have done it a much better or easier way.  So, I
> start over implementing what I've learned.  But it's fun, and I love
> learning.
> 

In many projects, it would be advisable to "build one to throw away".
Usually when we are learning a new technology, we are learning how
to do things the right way with it.  Then of course the project scope
itself as changed as one figures out what it should really do anyway.

So we are either left with maintaining something that should be thrown away,
or redoing it from scratch.  Not a lot of folks have the patience or time
for the latter, however good project practice it may be.  "Management" all
too often thinks a prototype is a fully implemented version ready to maintain
and extend for the entire project life cycle when little proper engineering
has gone into it.

I just liked your sentiment so I wanted to wax a bit on it.  I haven't
reimplemnted something for fun for quite a while, perhaps I have gotten
too jaded, and I found sentiment inspiring :)  Don't worry, I won't
reimplement Apache::ASP from scratch, I'll take my inspiration out
on something else!

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checker                 http://www.nodeworks.com


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


Re: Session->Abandon question

Posted by "D. L. Fox" <df...@netpath.net>.
----- Original Message -----
From: "Ian Cass" <ia...@mblox.com>
To: <as...@perl.apache.org>
Sent: Thursday, September 04, 2003 4:44 AM
Subject: Re: Session->Abandon question


> The point at which you should start worrying is when you write something &
> don't have a better idea afterwards :)

Point well taken.  I hadn't thought of it that way.  Now I don't feel so bad
about all the re-writing I do.  :)


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


Re: Session->Abandon question

Posted by Ian Cass <ia...@mblox.com>.
D. L. Fox wrote:
> I have been re-writing much of what I had anyway.  I find myself
> doing this alot whenever I take on a new project.  It seems when I
> almost complete working on something new, an idea about a different
> way of doing it comes to me, and I realize I could have done it a
> much better or easier way.  So, I start over implementing what I've
> learned.  But it's fun, and I love learning.

The point at which you should start worrying is when you write something &
don't have a better idea afterwards :)

--
Ian Cass


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


Re: Session->Abandon question

Posted by "D. L. Fox" <df...@netpath.net>.
----- Original Message -----
From: "Josh Chamas" <jo...@chamas.com>
> What this means though is that data in $Session is not cleaned up when
> $Session->Abandon is called, but this is a good thing because the
> Session_OnEnd event has not been called yet, and it needs to have a
> chance to work on the $Session data.

Oh, yeah.  I see what you mean.  I didn't stop to think about Session_OnEnd
needing a chance to run.

> So if you really want to get rid of the $Session data immediately, what
> you are doing is fine, but an even easier way would be to just:
>
>    %$Session = ();

DOH...I should have thought of that.  Thanks for the response, Josh.

I have been re-writing much of what I had anyway.  I find myself doing this
alot whenever I take on a new project.  It seems when I almost complete
working on something new, an idea about a different way of doing it comes to
me, and I realize I could have done it a much better or easier way.  So, I
start over implementing what I've learned.  But it's fun, and I love
learning.


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


Re: Session->Abandon question

Posted by Josh Chamas <jo...@chamas.com>.
D. L. Fox wrote:
> Can $Session->Abandon be called from an include file, even if
> $Response->TrapInclude is used?  Does the user have to navigate (or be
> redirected) to another page for it to "take effect"?
> 
> Although I have been using Apache-ASP for some time, I am new to using the
> Session object.  I started playing with it at home on my win98SE machine.
> I'm using Apache 1.3.27, Perl 5.6.1 built for MSWin32-x86-multi-thread
> (ActiveState), mod_perl is listed as 1.28 on the perl.apache.org site,
> although it shows 1.27_01-dev when viewing the output of %ENV.
>
...
 >
 > I did a "workaround", although I don't know if it's a Good Thing to do, or
 > the Right Thing to do.
 >
 > foreach my $skey(keys(%{$Session})) {
 >     $Session->{$skey} = undef;
 > }
 >

What *should* happen with $Session->Abandon is that it is set for
cleanup immediately, which occurs after the current request is processed.
What this means though is that data in $Session is not cleaned up when
$Session->Abandon is called, but this is a good thing because the
Session_OnEnd event has not been called yet, and it needs to have a
chance to work on the $Session data.

After $Session->Abandon gets called, the next web request, the user
will get a new session because the current session-id is invalid.

So if you really want to get rid of the $Session data immediately, what
you are doing is fine, but an even easier way would be to just:

   %$Session = ();

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checker                 http://www.nodeworks.com


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