in reply to A case for enviromental conservation?

I'm sure I've done something awefull

Awefull, as in "I am full of awe" well yes, because, basically, you can't do that. The environment table is a simple hash of scalars, to put it in terms of Perl. You can't create references to hashes as values of environment variables. If you were brave and insisted on that approach, you could try $ENV{FOO} = "var=$var:foo=$foo:this=$this and then retrieve the information by first splitting on : and then splitting on =. Or regexps, whatever.

But even if that were possible, it still wouldn't help you very much, because setting environment variables in a web process does not mean that you are guaranteed that a given process x that dealt with the initial contact of client y will deal with that same client y in subsequent transactions. This is because of the stateless nature of the HTTP protocol. There is nothing in a client transaction (whether it be a GET, POST or whatever) that ties it to any other transaction either in the past or the future.

To store authentication data, you have to pass an unguessable (read: random) string of bytes back to the client that serves as a unique identifier, so that the next time they return to your site, you know that you have seen them before. The two simplest ways a client has of returning you this unique identifier is either as a cookie, or as a parameter on a POST or GET request.

If that doesn't make much sense, just holler, and I (or someone else) will elaborate (but the fact that you use a hash of hashes indicates that you are not a complete beginner).

btw, it's "environmental"


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

Replies are listed 'Best First'.
Re: Re: A case for environmental conservation?
by caedes (Pilgrim) on Jun 17, 2002 at 00:53 UTC
    Thanks for the concern, but I have the state-based authentication all figured out. And just so you know, it is possible to add hashrefs to the %ENV. I've done it nested four levels deep with no problem. PS: How did I spell "environmental" before?
      And just so you know, it is possible to add hashrefs to the %ENV.
      Oops! That will break Perl's multi-platform portability. %ENV is tied to the operating system's environment handling. This will definitely break on VMS, as %ENV is implemented in logical name tables, which are strange beasts (to the non-VMS hacker).
        Whoa! That's good to know. I never expected portability issues with the use of a simple variable. On the other hand i don't see myself working on a machine with VMS in the near future, but you never know.