You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ml <ml...@blas.net> on 2000/02/28 21:47:14 UTC

Want to have a relative EMBPERL_COOKIE_EXPIRES variable !

I try to find an answer in the mailing-list history : nothing.

Using the EmbPerl post 1.2.1 and mod_perl 1.2.1 under Apache 1.3.11 I'd
like to be able to specify a length for the COOKIE_EXPIRES variable and not
a fixed date.


EMBPERL_COOKIE_EXPIRES='+1M' doesn't work since it doesn't use CGI::Cookie
subroutine.


What is the best way to handle cookie_expires while using %udat and 
Apache::Session for commodity and transparency and no Execute ?

Do I need to modify Embperl.pm or Session.pm scripts ?


Thanks,

db



RE: Want to have a relative EMBPERL_COOKIE_EXPIRES variable !

Posted by Kee Hinckley <na...@somewhere.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Okay, that was a wonderful example of why not to post software at 
three in the morning.  Later today I'll put out an updated release 
with a better classname, no debug statements, and no global variables.
- -- 

Kee Hinckley - Somewhere Consulting Group - Cyberspace Architects(rm)

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.2 for non-commercial use <http://www.pgp.com>

iQA/AwUBOPiB8CZsPfdw+r2CEQIf0gCgzY2LUNj+r/QPNd41EIqvAa9qau4AmQGS
0hbtj1yUGjltirPZ8KS3eQfo
=5NKb
-----END PGP SIGNATURE-----

RE: Want to have a relative EMBPERL_COOKIE_EXPIRES variable !

Posted by Kee Hinckley <na...@somewhere.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 9:51 PM +0100 2/28/00, Gerald Richter wrote:
>EMBPERL_COOKIE_EXPIRES is simply passed to the Cookie header. So everything
>what the browsers understand will work here. For everything else you need to
>patch Embperl.pm (and send me the patch :-)

...

>  >
>>  Using the EmbPerl post 1.2.1 and mod_perl 1.2.1 under Apache 1.3.11 I'd
>>  like to be able to specify a length for the COOKIE_EXPIRES
>>  variable and not
>  > a fixed date.

Okay, this is real ugly, but it seems to work.

I looked at the EmbPerl code and decided that for now I'll leave 
patching it to Gerald.  Clearly that's where this should be done. 
But in the meantime I wanted relative cookie expirations. 
Furthermore, I wanted to be able to modify the expiration on the fly 
in a given HTML file.  I did not succeed at the latter (the cookie 
values are set before the code executes), but I did get the former to 
work.

Feel free to update/fix/criticize this.  Also I ought to change the 
package name, and any number of other things, but I'd like to get 
comments first.

Put this in your apache config file:

         <perl>
             use Expires;
             tie $ENV{'EMBPERL_COOKIE_EXPIRES'}, 'Expires', 60*24*30*6;
         </perl>

The final argument is the number of minutes you want the cookie to 
stay around.  You don't need to call PerlSetEnv.  The above example 
is set for approximately six months.

Then put this in your INC path as "Expires.pl".  As I say, docs will 
come.  But basically it works this way.  Whenever 
$ENV{'EMBPERL_COOKIE_EXPIRES'} is referenced, it returns a valid 
expiration string N minutes in the future.  EmbPerl references it 
everytime it calls Execute, so that works fine.  If you don't give it 
the third argument at creation time, then it will default to an empty 
string, and no expiration date will be set (EmbPerl doesn't put in 
the "Expires" flag if the value is empty).  If you want to set 
$ENV{'EMBPERL_COOKIE_EXPIRES'} you can, just set it to the number of 
minutes you want the cookie to last.  But unfortunately you can't do 
this in your HTML files, only in the config file.

If that's not clear (and it's three in the morning, so I wouldn't be 
surprised), feel free to drop me email.

package Expires;
use strict;

use Date::Format;

sub After {
     my ($newmin) = @_;
     $Expires::Minutes = $newmin;
}

sub String {
     return '' if ($Expires::Minutes == 0);
     return time2str('%a, %e %h %Y %T %Z', time+($Expires::Minutes*60), 'GMT');
}

sub TIESCALAR {
     print STDERR "TIESCALAR\n";
     my ($pkg, @rest) = @_;
     my $obj = String();
     After(@rest) if (@rest);
     return (bless \$obj, $pkg);
}

sub FETCH {
     print STDERR "FETCH\n";
     my ($obj) = @_;
     return String();
}

sub STORE {
     print STDERR "STORE\n";
     my ($obj, $val) = @_;
     After($val);
}

1;

- -- 

Kee Hinckley - Somewhere Consulting Group - Cyberspace Architects(rm)

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.2 for non-commercial use <http://www.pgp.com>

iQA/AwUBOPgRdCZsPfdw+r2CEQIW7wCeIg0vVI3BhmxrR0nSc/NJEzcZC1YAoP0d
9ZU+TJSCeEef9cOX2rpy0qUQ
=X4xm
-----END PGP SIGNATURE-----

RE: Want to have a relative EMBPERL_COOKIE_EXPIRES variable !

Posted by Gerald Richter <ri...@ecos.de>.
EMBPERL_COOKIE_EXPIRES is simply passed to the Cookie header. So everything
what the browsers understand will work here. For everything else you need to
patch Embperl.pm (and send me the patch :-)

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925151
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------


> -----Original Message-----
> From: modperl-return-696-richter=ecos.de@apache.org
> [mailto:modperl-return-696-richter=ecos.de@apache.org]On Behalf Of ml
> Sent: Monday, February 28, 2000 9:47 PM
> To: 'modperl@apache.org'
> Subject: Want to have a relative EMBPERL_COOKIE_EXPIRES variable !
>
>
> I try to find an answer in the mailing-list history : nothing.
>
> Using the EmbPerl post 1.2.1 and mod_perl 1.2.1 under Apache 1.3.11 I'd
> like to be able to specify a length for the COOKIE_EXPIRES
> variable and not
> a fixed date.
>
>
> EMBPERL_COOKIE_EXPIRES='+1M' doesn't work since it doesn't use CGI::Cookie
> subroutine.
>
>
> What is the best way to handle cookie_expires while using %udat and
> Apache::Session for commodity and transparency and no Execute ?
>
> Do I need to modify Embperl.pm or Session.pm scripts ?
>
>
> Thanks,
>
> db
>
>
>