473,545 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you acceess $_SESSION from within CLI PHP script?

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.

Thanx
Phil

Apr 26 '06 #1
5 13232
comp.lang.php said the following on 26/04/2006 23:09:
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?
--
Oli
Apr 26 '06 #2

Oli Filth wrote:
comp.lang.php said the following on 26/04/2006 23:09:
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($_REQ UEST) 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!

Phil

--
Oli


Apr 26 '06 #3
>Is it possible to access values preset from $_SESSION from within a CLI
PHP page?
There are no sessions for command-line PHP. There aren't any "pages",
either, just command scripts. Also no $_GET, $_POST, $_REQUEST, or $_COOKIE.
But there are command-line arguments.
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?
How does one "call" something that's not code? You could pass command-line
arguments. Those are strings, not arrays.
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.


Why are you using CLI PHP invoked from a form? It seems like a classic
case of trying to drive in nails with a squirrel because you had a squirrel
handy. Use the right tool for the job, which I suspect may involve
include, require, and/or eval and no separate CLI anything.

Gordon L. Burditt
Apr 27 '06 #4
>> > 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($_REQ UEST) 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.

Gordon L. Burditt
Apr 27 '06 #5

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($_REQ UEST) 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


Apr 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
23296
by: DS | last post by:
In client-side script (<script> codes </script>), how can set / get session variables' values? Pls advise. DS
2
13523
by: Eric | last post by:
Hi, I've a problem with trying to retrieve a session variable in an include file. Basically, the main asp creates a session variable: <% Session("var1") = "Hello" %> And then when I click on a button it refers to the include file, which I believe is all client-side code as there are no server <% %> tags.
4
8899
by: Gregory Pearce | last post by:
Hi, Can anyone tell me if it is possible to access a session within a class? I have created a class that has if ((Session == null) etc.... However upon building the project, the name Session has a problem. I have tried adding usingSystem.Web etc to the class however cannot seem to rectify the problem.
4
1630
by: thdevdex | last post by:
Needless to say I'm new to .Net. I'm trying to set Session variables from within a method within a class. (Name "Session" is not declared) is the message I get while typing in the code. I don't get this while entering code within an .aspx.vb file. Obviously I need to create and instance of some System.Web... object but I don't know what...
2
1132
by: Gregory Pearce | last post by:
Hi, Can anyone tell me if it is possible to access a session within a class? I have created a class that has if ((Session == null) etc.... However upon building the project, the name Session has a problem. I have tried adding usingSystem.Web etc to the class however cannot seem to rectify the problem.
4
17919
by: Kevin Murphy | last post by:
This is a tip for the record in case it helps somebody else in the future. I have an import script that relies on a stored procedure that runs as a trigger on inserts into a temporary table. The script looks like this: -- create table -- ... -- define procedure and trigger
2
5277
by: Yansky | last post by:
Hi, I was just wondering if it is possible to disable script debugging in IE from within a script. I know I can disable it manually through the IE tools menu, but is it possible to disable it from within a script? e.g. debug = false; or something? I've googled, but all the results show the manual way through the tools menu.
2
2839
by: rsprung | last post by:
I haven't used Perl in many years, and can't remember how to do this. If I invoke my script with 'fixhbm.pl 2>fixhbm.errlog', STDERR is redirected to a file and stays out of my console output. How do I accomplish the same within the program?
1
1764
by: shank | last post by:
I have the below code to auto-email a customer. What is the syntax to include a file in the email? <!--#include file="agreement_inc.asp" --> HTML = HTML & "...just some text...<br>" HTML = HTML & <!--#include file="agreement_inc.asp" --> HTML = HTML & "</body>" HTML = HTML & "</html>"
1
1763
AdminCyn
by: AdminCyn | last post by:
I am working on a project to update our website functionality; mainly I am suppose to create an HTML form for prospective tenants to fill out and submit via email; I have the html form done and looking wonderful but an struggling with the php script to email the form contents; I have written a php script to email a form; I keep getting these...
0
7432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.