|
Posted by Richard Lynch on 10/04/13 11:08
Eli wrote:
> 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.
I THINK you MIGHT be able to use some session functions to set the session
name and session file when you do session_start() and get PHP to do all
the work of the reading/writing the files. You just need to pass in the
session ID to session_name() or session_start() or something like that. I
forget how to do this, but I did it once when I couldn't get trans-sid to
work, and it was a one-line solution. Try to find it. Maybe session_id()
takes an optional argument.
If that fails, then here's option 2:
There is sample code for storing your session data in MySQL on the
web-site in the manual.
You could easily take that code and swap out the MySQL bits to just
read/write your own session files, or go ahead and use MySQL if it's okay
security-wise, or put the data anywhere you feel appropriate for your
application.
If that's not auitable, to answer your original question :-) is Option 3:
I think the session files consist of a series of variable names and
serialized values separated by semi-colons or something like that.
So to read/write the session files would be something not unlike:
$data = file($session_file);
$elements = explode(';', $data);
while (list(, $element) = each($elements)){
list($var, $serialized) = explode(':', $element);
$$var = unserialize($serialized);
}
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|