Re: [PHP-DB] Re: [PHP] SESSIONS - SOLVED

2015-01-02 Thread Bastien Koert
No worries, Ethan. Sometimes we all try to outsmart ourselves by doing
something new.

Can I ask why you're opening a new window? Could the script not simply be
included in the original PHP code and avoid the window open? I ask because
pop up blockers may inhibit the functionality required. Or could you
perhaps do an ajax request back to the server to fire off the script?

Bastien
On Thu, Jan 1, 2015 at 11:59 PM Ethan Rosenberg 
erosenb...@hygeiabiomedical.com wrote:

 Bastein -

 Correct 100%.  I feel rather stupid.  A POST or GET will cause session
 variables to be transferred.

  From another post to the UNIX list, this works.

 script type=text/JavaScript
 !--
 window.open(HandleFood.php,_self)
 //--\
 /script

 and the SESSION variables transfer.

 Sorry for bothering you with such trivia.

 Ethan
 --

 On 01/01/2015 11:21 PM, Bastien Koert wrote:
  Ethan,
 
  As was explained in another post, sessions DO NOT WORK when you call
 shell_exec because the browser
  the user is using holds the session cookie WHICH IS NOT AVAILABLE during
 a shell_exec
 
  This is totally expected behavior. If you need to call the second script
 via a cron for example, no
  session variables will exist. Your script would have to generate those
 values (perhaps from a
  database call to some table) to have those available in the script.
 
  If your first script is calling shell_exec ( calling shell_exec from a
 script to another script in
  processing a browser call is just weird) then you would have to pass the
 session values you need in
  the shell_exec call as parameters.
 
  Bastien
  On Thu, Jan 1, 2015 at 11:13 PM Ethan Rosenberg, PhD 
 erosenb...@hygeiabiomedical.com
  mailto:erosenb...@hygeiabiomedical.com wrote:
 
  Dear List -
 
  I can make it work, but I do not know why???
 
  I have two scripts, HandleWeight and HandleFood.
 
  I call HandleWeight from a form ...
 
 
  echo form method= 'post' action='HandleWeight.php';
  echo centerstronginput type = 'submit' value=
 'WEIGH'/strong/center;
  echo /form;
 
  and the session variables appear in HandleWeight.
 
  I call HandleFood with a shell_exec,
 
  $output = shell_exec('php HandleFood.php');
 
  and the variables do not appear in HandleFood.
 
  If I call it from a form, the variables appear.
 
  What is going on??
 
  TIA
 
  Ethan
  --
 
  On 01/01/2015 07:39 PM, David OBrien wrote:
   
   
On Thursday, January 1, 2015, Stuart Dallas stu...@3ft9.com
 mailto:stu...@3ft9.com
  mailto:stu...@3ft9.com mailto:stu...@3ft9.com wrote:
   
Before I look at the code in any sort of detail, what do you
 mean by from
the terminal?
   
On Friday, January 2, 2015, Ethan Rosenberg
 erosenberg@hygeiabiomedical.__com
  mailto:erosenb...@hygeiabiomedical.com javascript:;
wrote:
   
  Dear List -
 
  My session variables do not seem to propagate
 
  a.php
 
  ?php
 
  session_name(STORE);
  session_set_cookie_params( '24000', '/' );
  session_start();
  ?
 
  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
 Transitional//EN 
  http://www.w3.org/TR/xhtml1/__DTD/xhtml1-transitional.dtd
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
 
  snip
 
  global $cxn;
  global $sale;
  global $tax_rate;
  global $tax;
  $upc = $_POST['UPC'];
  $_SESSION['UPC'] = $_POST['UPC'];
  snip
 
  case 'step3':
  {
  echo 'step3';
  global $cxn;
  global $sale;
  global $tax_rate;
  global $tax;
  $upc = $_POST['UPC'];
  $_SESSION['UPC'] = $_POST['UPC'];
  echo 'sess';
  print_r($_SESSION);
  echo 'br /';
  if(strlen($upc) 5) // the value is a
 4 digit
  // code, which is used for fruits
 and vegatables
  {
  $sql7 = select WeightFlag from
 Food where PLU =
  $upc;
  $result7 = mysqli_query($cxn,
 $sql7);
  $row7 = mysqli_fetch_row($result7);
 
  }
  echo 'row7';
  print_r($row7);
  if($row7[0] != 0)
  {
 
 

[PHP-DB] Re: [PHP] SESSIONS - SOLVED

2015-01-01 Thread Ethan Rosenberg

Bastein -

Correct 100%.  I feel rather stupid.  A POST or GET will cause session 
variables to be transferred.

From another post to the UNIX list, this works.

script type=text/JavaScript
!--
window.open(HandleFood.php,_self)
//--\
/script

and the SESSION variables transfer.

Sorry for bothering you with such trivia.

Ethan
--

On 01/01/2015 11:21 PM, Bastien Koert wrote:

Ethan,

As was explained in another post, sessions DO NOT WORK when you call shell_exec 
because the browser
the user is using holds the session cookie WHICH IS NOT AVAILABLE during a 
shell_exec

This is totally expected behavior. If you need to call the second script via a 
cron for example, no
session variables will exist. Your script would have to generate those values 
(perhaps from a
database call to some table) to have those available in the script.

If your first script is calling shell_exec ( calling shell_exec from a script 
to another script in
processing a browser call is just weird) then you would have to pass the 
session values you need in
the shell_exec call as parameters.

Bastien
On Thu, Jan 1, 2015 at 11:13 PM Ethan Rosenberg, PhD 
erosenb...@hygeiabiomedical.com
mailto:erosenb...@hygeiabiomedical.com wrote:

Dear List -

I can make it work, but I do not know why???

I have two scripts, HandleWeight and HandleFood.

I call HandleWeight from a form ...


echo form method= 'post' action='HandleWeight.php';
echo centerstronginput type = 'submit' value= 
'WEIGH'/strong/center;
echo /form;

and the session variables appear in HandleWeight.

I call HandleFood with a shell_exec,

$output = shell_exec('php HandleFood.php');

and the variables do not appear in HandleFood.

If I call it from a form, the variables appear.

What is going on??

TIA

Ethan
--

On 01/01/2015 07:39 PM, David OBrien wrote:
 
 
  On Thursday, January 1, 2015, Stuart Dallas stu...@3ft9.com 
mailto:stu...@3ft9.com
mailto:stu...@3ft9.com mailto:stu...@3ft9.com wrote:
 
  Before I look at the code in any sort of detail, what do you mean by 
from
  the terminal?
 
  On Friday, January 2, 2015, Ethan Rosenberg 
erosenberg@hygeiabiomedical.__com
mailto:erosenb...@hygeiabiomedical.com javascript:;
  wrote:
 
Dear List -
   
My session variables do not seem to propagate
   
a.php
   
?php
   
session_name(STORE);
session_set_cookie_params( '24000', '/' );
session_start();
?
   
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/__DTD/xhtml1-transitional.dtd
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
   
snip
   
global $cxn;
global $sale;
global $tax_rate;
global $tax;
$upc = $_POST['UPC'];
$_SESSION['UPC'] = $_POST['UPC'];
snip
   
case 'step3':
{
echo 'step3';
global $cxn;
global $sale;
global $tax_rate;
global $tax;
$upc = $_POST['UPC'];
$_SESSION['UPC'] = $_POST['UPC'];
echo 'sess';
print_r($_SESSION);
echo 'br /';
if(strlen($upc) 5) // the value is a 4 digit
// code, which is used for fruits and 
vegatables
{
$sql7 = select WeightFlag from Food 
where PLU =
$upc;
$result7 = mysqli_query($cxn, $sql7);
$row7 = mysqli_fetch_row($result7);
   
}
echo 'row7';
print_r($row7);
if($row7[0] != 0)
{
   
   
echo form method= 'post'
action='HandleWeight.php';
echo centerstronginput type = 
'submit'
value= 'WEIGH'/strong/center;
echo /form;
exit();
}
echo 'SQL11';
$sql11= $row[7] IS  NULL OR $row[7] == '' ;
if($sql11)
print_r($_POST);
print_r($_SESSION);
{
   
$output = shell_exec('php 
HandleFood.php');