By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

Must set and immediately get $_SESSION variable - help!

P: n/a
This is an urgent request (as always)

Expand|Select|Wrap|Line Numbers
  1.  
  2. generate_admin_customer_position_dropdown($customerResult,
  3. $customerResult[0]->id);
  4. print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
  5.  
This code will generate an HTML dropdown as well as set a $_SESSION
variable.

I can verify the function works perfectly and in fact sets the session
variable every time. Problem is that I need to set and then
IMMEDIATELY get the session variable w/o redirection because
redirection is undoable at the portion of the PHP code that this must
work in.

What do I do? Each time I try this the session variable is NOT
immediately available until a latter iteration renders it available but
far too late to be used.

How do I set and then IMMEDIATELY get a SESSION variable? This is an
urgent request!!

Thanx
Phil

Feb 26 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
comp.lang.php wrote:
This is an urgent request (as always)

Expand|Select|Wrap|Line Numbers
  1.       generate_admin_customer_position_dropdown($customerResult,
  2.  $customerResult[0]->id);
  3.       print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
  4.  

This code will generate an HTML dropdown as well as set a $_SESSION
variable.

I can verify the function works perfectly and in fact sets the session
variable every time. Problem is that I need to set and then
IMMEDIATELY get the session variable w/o redirection because
redirection is undoable at the portion of the PHP code that this must
work in.

What do I do? Each time I try this the session variable is NOT
immediately available until a latter iteration renders it available but
far too late to be used.

How do I set and then IMMEDIATELY get a SESSION variable? This is an
urgent request!!

Thanx
Phil


Maybe just store it in a work variable? Why does it HAVE to come from
the $_SESSION variable?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 26 '06 #2

P: n/a
"comp.lang.php" <ph**************@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
This is an urgent request (as always)

Expand|Select|Wrap|Line Numbers
  1.  generate_admin_customer_position_dropdown($customerResult,
  2.  $customerResult[0]->id);
  3.  print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
  4.  

This code will generate an HTML dropdown as well as set a $_SESSION
variable.

I can verify the function works perfectly and in fact sets the session
variable every time. Problem is that I need to set and then
IMMEDIATELY get the session variable w/o redirection because
redirection is undoable at the portion of the PHP code that this must
work in.

What do I do? Each time I try this the session variable is NOT
immediately available until a latter iteration renders it available but
far too late to be used.

How do I set and then IMMEDIATELY get a SESSION variable? This is an
urgent request!!

Thanx
Phil


Not exactly sure what you mean... How can you verify that the $_SESSION
variable is set if you also state you can't access it.

place this before your print_r statement: echo "<!-- SESSION
status:\n\r".var_dump($_SESSION)."\n\r-->";

then look in the source code of the resulting page. This will show you all
the $_SESSION variables and their values.

I can set a session and immediatley access it all day long... it has to be
something else. To me it appears that this could be the culprit:

print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);

....what is "${projectAcronym}_customerSOWObjectArray"? In otherwords what
is 'projectAcronym'? It can do it this way too, no problem. If
'projectAcronym' is a variable (it really has a $ in front of it) then you
need to make sure it is set properly. The $ can go inside the curly braces
as well and should keep things easier to read. Just try entering the little
code snippet above and you'll see what the session variables are.

Norm


Feb 26 '06 #3

P: n/a

Jerry Stuckle wrote:
comp.lang.php wrote:
This is an urgent request (as always)

Expand|Select|Wrap|Line Numbers
  1.  >
  2.  >      generate_admin_customer_position_dropdown($customerResult,
  3.  > $customerResult[0]->id);
  4.  >      print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
  5.  > 

This code will generate an HTML dropdown as well as set a $_SESSION
variable.

I can verify the function works perfectly and in fact sets the session
variable every time. Problem is that I need to set and then
IMMEDIATELY get the session variable w/o redirection because
redirection is undoable at the portion of the PHP code that this must
work in.

What do I do? Each time I try this the session variable is NOT
immediately available until a latter iteration renders it available but
far too late to be used.

How do I set and then IMMEDIATELY get a SESSION variable? This is an
urgent request!!

Thanx
Phil

Maybe just store it in a work variable? Why does it HAVE to come from
the $_SESSION variable?


The function returns an HTML string variable, I don't know of any other
way in PHP to store it for latter (but immediate) retrieval other than
via $_SESSION.

Else, please explain "work variable" to me.

Phil
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Feb 27 '06 #4

P: n/a

Norman Peelman wrote:
"comp.lang.php" <ph**************@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
This is an urgent request (as always)

Expand|Select|Wrap|Line Numbers
  1.  >
  2.  > generate_admin_customer_position_dropdown($customerResult,
  3.  > $customerResult[0]->id);
  4.  > print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
  5.  > 

This code will generate an HTML dropdown as well as set a $_SESSION
variable.

I can verify the function works perfectly and in fact sets the session
variable every time. Problem is that I need to set and then
IMMEDIATELY get the session variable w/o redirection because
redirection is undoable at the portion of the PHP code that this must
work in.

What do I do? Each time I try this the session variable is NOT
immediately available until a latter iteration renders it available but
far too late to be used.

How do I set and then IMMEDIATELY get a SESSION variable? This is an
urgent request!!

Thanx
Phil

Not exactly sure what you mean... How can you verify that the $_SESSION
variable is set if you also state you can't access it.

place this before your print_r statement: echo "<!-- SESSION
status:\n\r".var_dump($_SESSION)."\n\r-->";

then look in the source code of the resulting page. This will show you all
the $_SESSION variables and their values.

I can set a session and immediatley access it all day long... it has to be
something else. To me it appears that this could be the culprit:

print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);

...what is "${projectAcronym}_customerSOWObjectArray"? In otherwords what
is 'projectAcronym'? It can do it this way too, no problem. If
'projectAcronym' is a variable (it really has a $ in front of it) then you
need to make sure it is set properly. The $ can go inside the curly braces
as well and should keep things easier to read. Just try entering the little
code snippet above and you'll see what the session variables are.


Thanks, however, over the weekend I was able to brute-force it to work
by rewriting the entire function. To not dump out a 100-line function
to solve you all the heartache of dealing with mounds of raw code,
basically, it works now, sets and gets $_SESSION variable as it should,
so thanx!

Phil
Norm


Feb 27 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.