Stas Bekman <[EMAIL PROTECTED]> writes: > James Taylor wrote: > > I'm having difficulty getting my mod_perl scripts and then my > > non-mod_perl scripts reading cookies between each other. I have a > > mod_perl TransHandler that sets a cookie via Apache::Cookie, and > > then I have some scripts in my /cgi-bin that try and read the cookie > > using basic CGI::Cookie. It doesn't appear to be working > > whatsoever, as the Apache::Cookie script can't read any of the > > cookies set by CGI::Cookie and vice-versa. I tried ditching > > Apache::Cookie in the transhandler and using CGI::Cookie as well, > > but still the two can't see each other. > > Any ideas what would cause something like this? > > > You can't do it this way. Since when you try to retrieve the cookie > from your cgi, it reads the cookies from $ENV{HTTP_COOKIE} || > $ENV{COOKIE}, whereas your TransHandler doesn't set those env-vars > (one of the two), and that's what it should do. Moreover, most likely > it should use $r->subprocess_env to do that, and not setting %ENV.
Amplififying on Stas's reply, there's a big difference between incoming (request) cookies and outgoing (response) cookies. When you set (or bake) a cookie, it's _outgoing_, so you're ultimately creating something that will only appear in the *response* headers. On the other hand, when these modules parse cookies, they're only looking at the *request* headers, since that's where the *incoming* cookies appear. IOW, you shouldn't try to set/bake cookies as a means of passing data from one handler to another one *inside the same request*. Cookies are a means of passing data between two different requests, and the module APIs reflect that. -- Joe Schaefer -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html