You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "Steven D. Arnold" <st...@permanent.cc> on 2000/05/01 22:21:52 UTC

reading cookies, and a bug

I have looked through the FAQ, the docs and what I have received so far on 
this list and I am still unclear on how to /read/ cookies in EmbPerl. I do 
know how to send them. I can also read them with CGI.pm within EmbPerl, but 
surely there must be a way to do this directly in EmbPerl. Anyone have a 
clue I can borrow?

Also, I have noticed that when I restart apache, usually EmbPerl will not 
run any scripts I have been working on; when I connect to the server, it 
sits there forever and the script never runs, or at least never returns a 
result to the browser.  However, as soon as I make a change to the script 
and save, the script will run.  This sounds like a caching bug.  The 
obvious workaround is to re-save the file.


steve


RE: reading cookies, and a bug

Posted by Gerald Richter <ri...@ecos.de>.
>
> I am not in a place where I can ssh to the machine on which I was having
> the problem, so I will followup to this post tomorrow with a more
> confident
> answer.  However, I thought I was using the latest stable version, 1.2.1.
>

Another thing comes to my mind. Do you have compiled mod_perl as DSO? If
yes, you need at least mod_perl 1.22 (or link it staticly into Apache),
otherwise you will run into such strange errors.

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
-------------------------------------------------------------



RE: reading cookies, and a bug

Posted by "Steven D. Arnold" <st...@permanent.cc>.
<<< No Message Collected >>>

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


RE: reading cookies, and a bug

Posted by "Steven D. Arnold" <st...@permanent.cc>.
At 06:04 AM 5/2/2000 +0200, Gerald Richter wrote:

>I agree to you that there is no reason to not include it in Embperl, other
>than the time it takes to do so. I put it on the TODO list (but there are
>already I lot of things todo). Anyway you are free to send me a patch and I
>will be happy to include it in Embperl.

*nod*  EmbPerl is a great tool overall; given that I have a cookie 
workaround, my concern is merely a minor complaint.  Nevertheless, your 
point about making a patch is well taken; I'll do that.


> >Also, I have noticed that when I restart apache, usually EmbPerl will not
> >run any scripts I have been working on; when I connect to the server, it
> >sits there forever and the script never runs, or at least never returns a
> >result to the browser.  However, as soon as I make a change to the script
> >and save, the script will run.  This sounds like a caching bug.  The
> >obvious workaround is to re-save the file.
>
>Steven, which version of Embperl you are using? There is no caching bug in
>the current version of Embperl. There must be another reason for this strang
>behaviour.

I am not in a place where I can ssh to the machine on which I was having 
the problem, so I will followup to this post tomorrow with a more confident 
answer.  However, I thought I was using the latest stable version, 1.2.1.


>Looks like more to me, that your code needs a recompile before it could run
>correctly after a restart.
>
>Please try to put various
>
>[- warn "text" ; -]
>
>in your script, to see if it ever get called or where it stops working.
>
>Is this first request a POST request? Does it involve CGI.pm?

No, not a POST; the URL was of the form:

         http://aaa.bbb.ccc.ddd/embperl/login.html

It did involve CGI.pm; CGI.pm's sole function in the script is to fetch the 
user's cookie.  It was a login script that would check to see if you have a 
valid cookie which would authenticate you; if so, it would send you to the 
search page, else it would ask you to log in.


steve


RE: reading cookies, and a bug

Posted by Gerald Richter <ri...@ecos.de>.
Hi,
>
>
> >gerald's logic (probably, I can't speak for him :) is that there
> >should be no need for cookies - just use the %udat hash instead.
> >this eliminates the need for session-cookies, but there might still
> >be a need for saved (with Expire date) cookies in some situations.
>

You are wrong. There is no other reason for not supporting cookies directly
other then nobody has implemented it so far. If my logic were that %udat is
enought, then didn't had include questions about how to set a cookie in the
FAQ.

> I agree with your analysis.  In my case, we have many scripts, not just
> EmbPerl or even Perl at all.  My company uses an architecture that
> identifies customers based on cookies, and if EmbPerl couldn't work with
> that at all, we couldn't use EmbPerl.  Fortunately, CGI.pm allows me to
> read cookies, and you point out another method below.  But I
> can't see any
> reason not to include better control over cookies in EmbPerl itself.
>

I agree to you that there is no reason to not include it in Embperl, other
than the time it takes to do so. I put it on the TODO list (but there are
already I lot of things todo). Anyway you are free to send me a patch and I
will be happy to include it in Embperl.

>
> >at the moment, you can create the %cdat hash yourself with the
> >following code:
> >
> >   [-
> >     @ckpairs=split(/; /, $ENV{'HTTP_COOKIE'});
> >     foreach $pair (@ckpairs)
> >
> >      ($name, $value) = split(/=/, $pair); $cdat{$name}=$value;
> >     }
> >   -]
>
> Interesting, that gives me a useful piece of information too.  Thanks!
>
>
> > > This sounds like a caching bug.
> >
> >I don't know about this one, but Embperl has had numerous caching
> >issues in the past. I searched my mails and found one quick patch
> >that should fix at least some of the caching issues in the 1.2
> >versions:
>

This is an very dangerous answer! There were a caching bug in earliy 1.2
beta version (I think < 1.2b4). Nobody really should complain about a bug in
a that is more than a year old! If you send a patch, please tell to which
version is applies, otherwise you can make things more bad.

Most of the things what you call "numerous caching issues" are because of
problems people have with the fact how Perl manages it's modules and
namespaces and not due to Embperl.

>Also, I have noticed that when I restart apache, usually EmbPerl will not
>run any scripts I have been working on; when I connect to the server, it
>sits there forever and the script never runs, or at least never returns a
>result to the browser.  However, as soon as I make a change to the script
>and save, the script will run.  This sounds like a caching bug.  The
>obvious workaround is to re-save the file.

Steven, which version of Embperl you are using? There is no caching bug in
the current version of Embperl. There must be another reason for this strang
behaviour.

Looks like more to me, that your code needs a recompile before it could run
correctly after a restart.

Please try to put various

[- warn "text" ; -]

in your script, to see if it ever get called or where it stops working.

Is this first request a POST request? Does it involve CGI.pm?

Gerald


> Thanks for the tip!
>
>
> steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>


-------------------------------------------------------------
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
-------------------------------------------------------------


RE: reading cookies, and a bug

Posted by "Steven D. Arnold" <st...@permanent.cc>.
Hi Indrek,

Thanks for the feedback.

At 03:51 PM 5/1/2000 -0500, indrek siitan wrote:

>gerald's logic (probably, I can't speak for him :) is that there
>should be no need for cookies - just use the %udat hash instead.
>this eliminates the need for session-cookies, but there might still
>be a need for saved (with Expire date) cookies in some situations.

I agree with your analysis.  In my case, we have many scripts, not just 
EmbPerl or even Perl at all.  My company uses an architecture that 
identifies customers based on cookies, and if EmbPerl couldn't work with 
that at all, we couldn't use EmbPerl.  Fortunately, CGI.pm allows me to 
read cookies, and you point out another method below.  But I can't see any 
reason not to include better control over cookies in EmbPerl itself.


>at the moment, you can create the %cdat hash yourself with the
>following code:
>
>   [-
>     @ckpairs=split(/; /, $ENV{'HTTP_COOKIE'});
>     foreach $pair (@ckpairs)
>
>      ($name, $value) = split(/=/, $pair); $cdat{$name}=$value;
>     }
>   -]

Interesting, that gives me a useful piece of information too.  Thanks!


> > This sounds like a caching bug.
>
>I don't know about this one, but Embperl has had numerous caching
>issues in the past. I searched my mails and found one quick patch
>that should fix at least some of the caching issues in the 1.2
>versions:

Thanks for the tip!


steve


RE: reading cookies, and a bug

Posted by indrek siitan <tf...@cafe.ee>.
Hi,

> I have looked through the FAQ, the docs and what I have received
> so far on this list and I am still unclear on how to /read/
> cookies in EmbPerl. I do know how to send them. I can also read
> them with CGI.pm within EmbPerl, but surely there must be a way
> to do this directly in EmbPerl.

nope, there's no direct cookie access in Embperl. unfortunately,
'cause it shouldn't be that hard to implement something like %cdat
(similar to %fdat, %udat and %mdat).

gerald's logic (probably, I can't speak for him :) is that there
should be no need for cookies - just use the %udat hash instead.
this eliminates the need for session-cookies, but there might still
be a need for saved (with Expire date) cookies in some situations.

at the moment, you can create the %cdat hash yourself with the
following code:

  [-
    @ckpairs=split(/; /, $ENV{'HTTP_COOKIE'});
    foreach $pair (@ckpairs)

     ($name, $value) = split(/=/, $pair); $cdat{$name}=$value;
    }
  -]


> This sounds like a caching bug.

I don't know about this one, but Embperl has had numerous caching
issues in the past. I searched my mails and found one quick patch
that should fix at least some of the caching issues in the 1.2
versions:

--- 8< --- epmain.c --- 8< ---

    /* Have we seen this sourcefile already ? */
    ppSV = hv_fetch(pCacheHash, (char *)sSourcefile, strlen (sSourcefile),
0) ;
    if (ppSV && *ppSV)


--- 8< --- epmain.c --- 8< ---

set the if statement to something that's always false (for example,
"if (1==2)" :)


Rgds,
  Tfr

  --==< tfr@cafe.ee >==< http://tfr.cafe.ee/ >==< +1-504-4467425 >==--