RE: [PHP] Re: mediator between PHP and Perl (with sessions)
| From: | Warren Vail | Date: | Tue, 15 Feb 2005 16:52:09 +0000 |
| Subject: | RE: [PHP] Re: mediator between PHP and Perl (with sessions) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-208745@lists.php.net to get a copy of this message | ||
Eli,
Sessions work just fine with CLI (Command Line Interpreter), although there is little need for them
as a CLI script, since once started the script does not wait on user clicks of a browser for
it's next set of input, therefore no need to use sessions for passing information. Most CLI
scripts are started via a cron process, and if started from a webpage, the items passed to the
script can be passed via command line parameters, or if passed as session variables, the session key
needs to be passed to the CLI script, since CLI scripts don't have access to cookies. One
advantage of using session variables when starting a CLI script, is that the session may be able to
pass bigger values than can be contained in a command line. (Command line variables can be accessed
in the argc/argv array like in "c") and once passed this way the sessions are no longer
needed since your CLI script will run to completion.
If your server is a NIX box, you may have access to the "&" character after the
command name that will cause it to run as a separate shell script, but you will need to set the
timeout to allow it to run long enough, and if you do not use the "&" separate shell
character, the script will be interruptible by the user who started it by clicking a button like
"stop" on his browser.
The unserialize function is indeed used for sessions, but with most newer releases of PHP
"register variables" is turned off, which means the variables are not restored
automatically (you will find them in the $_SESSION array). Sections of the manual you may want to
reread are as follows;
http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/function.session-set-save-handler.php
(good illustrations of what happens in sessions)
http://www.php.net/manual/en/function.session-register.php
(notice the notes on register variables).
http://www.php.net/manual/en/function.session-id.php
http://us3.php.net/manual/en/function.set-time-limit.php
to allow script to run longer.
http://us3.php.net/manual/en/function.shell-exec.php
for starting a cli script (don't forget to start php).
hope this helps,
Warren Vail
> -----Original Message-----
> From: Eli [mailto:eli.hen@gmail.com]
> Sent: Tuesday, February 15, 2005 7:07 AM
> To: php-general@lists.php.net
> Subject: [PHP] Re: mediator between PHP and Perl (with sessions)
>
>
> It's quite easy to pass the session variables to the script. The problem
> with sessions and shell PHP scripts, is that PHP doesn't support
> sessions on that mode (CLI mode it is called). So, I would have to
> manualy read the session file and parse it. If anyone knows what is the
> exact function that is used to unserialize the session file, please
> tell.. and it's not the unserialize() function in PHP.
>
> I guess that using a shell PHP script with sessions is not the solution.
> Is anybody familiar with another way to use sessions??? but not through
> web, since the script returns sensitive data.
>
>
> -thanks, Eli
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>