Reply to Re: How do you acceess $_SESSION from within CLI PHP script?

Your name:

Reply:


Posted by comp.lang.php on 04/28/06 16:55

Gordon Burditt wrote:
> >> > Is it possible to access values preset from $_SESSION from within a CLI
> >> > PHP page? If so, how is it done? Each time I try to access $_SESSION
> >> > is an empty array; the moment I leave the CLI PHP and return to my
> >> > calling web-app PHP script, $_SESSION is back again, values and all,
> >> > completely untouched.
> >> >
> >> > Can $_SESSION be called? If not, then I have a bigger problem inasmuch
> >> > as $_REQUEST variables set via form/query-string MUST be accessed from
> >> > within CLI PHP script, and the only way I can think of is to put all of
> >> > $_REQUEST into $_SESSION, or what else do I do? Stumped.
> >>
> >> By definition, the CLI version of PHP is a stand-alone process. It's
> >> not tied in any way to a web-server, or an HTTP session, or anything
> >> like that. Consequently, the concept of GET/POST/session/cookie
> >> variables is meaningless in CLI PHP.
> >>
> >> Why are you calling CLI PHP from web-server-based PHP?
> >>
> >
> >Would you believe a requirement? Long story, but the architecture's
> >that way and that way to stay. I am trying to come up with a DB based
> >solution to this by stuffing serialize($_REQUEST) into a db table, but
> >I'm using $_SERVER['REMOTE_ADDR'] as the unique identifier for each
> >person's filtering request, and of course, when I select from within
> >the CLI PHP.. zappo! No criteria, because no $_SERVER!
>
> So pass the correct answer to the CLI PHP, and have it return it.
> That keeps the architecture but still gets the job done.
>
> You *CAN* pass command-line arguments (strings), which could include
> passing your unique identifier in.
>

What I wound up doing was to stuff the entire contents of $_REQUEST as
a serialized string into a database table and retrieving it that way
from within the CLI PHP. Thanx!
Phil

> Gordon L. Burditt

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация