Jump to content

[SOLVED] $_SESSION data unsetting!


scottybwoy

Recommended Posts

I want to use $_SESSION array as I want to hold some other data too, and this isn't working for some reason.  This script is run three times;

 

1st - Without any data sent - the form is just called.

2nd - With 'custId' sent - this data is then returned to the form.

3rd -With 'company' and 'clientId' sent - then back to the rest of the form.

 

What I want is all of that data stored as it comes available.  Seems simple enough, until I try it.  So what I have created is a $_SESSION var for each piece of data to make it simple;

 

$_SESSION['scustId'] = $custId,

$_SESSION['scompany'] = $company,

$_SESSION['sclientId'] = $clientId,

$_SESSION['sclient'] = $client.

 

Then further down I produce a printout of the $_SESSION data:

<?php
foreach($_SESSION as $key => $value){
	echo "<strong>".$key." : </strong>".$value."<br>";
}
?>

This holds all my $_SESSION vars from other pages in my script, but when it comes to this particular function, it works in a peculiar way.

 

1st execution - Prints out all previous $_SESSION data.

2nd execution - Prints out previous and 'scustId' + 'scompany', so far so good.

3rd execution - Prints out previous and 'sclientId' + 'sclient, 'scustId' + 'scompany' are gone!

 

What could be unsetting this data?  Here's the complete code :

<?php
function saleLoad() {
global $data_array;

$data_array = $_POST;

if (isset($data_array['custId']) && empty($data_array['company'])) {
	$_SESSION['scustId'] = $data_array['custId'];
	$_SESSION['scompany'] = $this->selectRecord('company', 'customers', 'custId', $data_array['custId']);
}

if (isset($data_array['clientId']) && empty($data_array['name'])) {
	$_SESSION['sclientId'] = $data_array['clientId'];
	$_SESSION['sclient'] = $this->selectRecord('name', 'client', 'clientId', $data_array['clientId']);
}

foreach($_SESSION as $key => $value){
	echo "<strong>".$key." : </strong>".$value."<br>";
}

if (!empty($_SESSION['scustId']) && !empty($_SESSION['sclientId'])) {
	//$this->salesPrep($_SESSION['s*']);
}

include_once(MK_SALE_PAGE);

}
?>

 

Thanks for your help.

Link to comment
Share on other sites

I'm using classes, so it's already started elsewhere.  I tried that but it just gave me a message telling me that its ignoring that command as it's already started.  Also if you read my post it does mention that it is holding the data stored prior to this script execution.

 

Thanks anyway

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.