Click to See Complete Forum and Search --> : Saving global variables in stateless forms


chuckdawit
06-14-2007, 08:13 PM
This question is similar to my last post in this forum. How can I save a global variable from a cgi script that calls different stateless forms. (ex. $global_var = $cgi->param('password') )
Here I want to save my password being returned from a form into a global variable named $global_var. When I try and do this and call another form it dumps the value of the global variable. How can I save this into a global variable?

Nedals
06-15-2007, 01:20 PM
Using cgi, you cannot have a variable that remains set for different calls to the script.

A 'Global' variable in Perl is one that can be accessed, assignedto, from anywhere within a running script. Usually it will be declared at the top of the script using 'my' or within a module, called by the script, using 'our'

If you need to set a 'session' variable you can use a cookie or a hidden field that is passed from page to page. (BUT DO NOT USE THE PASSWORD). Better to save a random string to the cookie or hidden field and link that back to the user/password that is saved in a file or database table on the server. (Typically known as authentication)