ido50 has asked for the wisdom of the Perl Monks concerning the following question:

CGI.pm again,
For some reason, CGI.pm keeps parameter values between program invocations. Probably a mod_perl or mod_cgi thing but I'm not sure. I'm trying to set a certain parameter, but nothing happens and the value from the previous program invocation is kept. I've tried using $q->delete_all before overriding, but it doesn't help. Even more, every time the program is invoked, I undef($q). But somehow it still keeps the last value.

What can I do?
Thanks.

-------------------------
Live fat, die young

Replies are listed 'Best First'.
Re: Can't override CGI parameters
by Joost (Canon) on Jun 11, 2004 at 11:53 UTC
      Okay here it is:
      * I don't know if it's mod_perl or mod_cgi, 'cause it is not my own server. I just have an account at a certain host.
      * $q->delete_all
      * What I'm talking about is a simple login form of the like $q->textfield('username') and $q->password_field('password'). When submitted, I get the values from the previuos invocation. In other words, from the previous time I've submitted the form.
      * I am not mixing OO and functional CGI calls.

      If you need to see some code, there's no problem, just tell me.
      Thanks.

      -------------------------
      Live fat, die young
        Alright, you can check if you're running as a CGI - check $ENV{GATEWAY_INTERFACE} - if it is "CGI/1.1" you're running as a CGI, if it's "CGI-Perl/1.1" you're running under mod_perl.

        $q->delete_all should remove all values from that query object, so any values that are in it after that, are put in there by you. More likely is that you create a new CGI object after that, which will again be initialized with the posted values.

        If you are running mod_perl and you are storing values in variables, it's possible that they will keep their value. They CGI object itself should not do that, unless you're not creating a new object for each request.

        How do you know that the values are the same as the previous request? Ie: how do you show them?

        Please show some code.

        1.. Find out what environment you are in, if it is a shared server then it is unlikely you are using mod_perl. To test what you have - telnet to the server on port 80, then issue the command:

        HEAD / HTTP/1.0

        The server will respond telling you what the Apache was compiled with.

        How do you know it is from a previous invocation? It could be the 'password manager' in the browser. Try two invocations from totally separate browsers (on the same machine and then on different machines).

        If that doesn't clear the problem - show us some code - as somebody asked for earlier. We are good, be we aren't phsycic.

        jdtoronto