How do I pass structured data to my (F) CGI via Apache?
We have an apache module for authentication. If the user can authenticate, the environment variable is REMOTE_USER
set to their username, where it is available to any available CGI.
I would like to add a function / module so that we can get more user information from the LDAP datasource and make it available to CGI and FCGI applications.
Since I know we can put information into the environment, is it advisable to store a more complex data structure (like JSON) in an environment variable? This seems awkward to me. Is there a better way to do this?
If it is language-specific, then Perl is what I'm most interested in, but it would be better if I could make this data available to any type of CGI or FCGI application. We are using Apache 2.2 on RHEL 5.0 (with SELinux enabled).
source to share
If you need to work with CGI, environment variables seem to be the only option (with mod_perl you can access Apache's internal data structures).
If the data is too large for the environment, you can create a temporary file and pass only the file name. You can also store this information in a database. In both cases, you probably have to worry about clearing out temporary data and concurrent race conditions.
If you already have persistent server-side session data (session file or directory or shared memory segment), you might want to put it there.
source to share