Jump to content

sessions


rn14

Recommended Posts

I have multiple objects each one is stored in a  separate session. Below I am unseriliazing the sessions and passing the values from each object to variables and then using them in a db query. The problem is the values I return from the first object are used as the values through all of the object I return on this page.

 

Should I be able to this??

 

Thanks

 

<?
session_start();
include('class.php');

$order = unserialize($_SESSION['order']);

$array = $order->getData();
$meal1 = $array[0];
$meal2 = $array[1];
$meal3 = $array[2];
$meal4 = $array[3];
$meal5 = $array[4];
$meal6 = $array[5];
$meal7 = $array[6];


include('config.php');
$link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die("Could not connect: " .
mysql_error());
mysql_select_db("_simp");
if (isset($meal1)){
$result = mysql_query("SELECT * FROM menus_show WHERE id = $meal1 ;");
while($row = mysql_fetch_array($result))
{
$image = $row['imagesmall'];
$title = $row['title'];
$description = $row['text'];
}


}



if (isset($meal2)){
$result = mysql_query("SELECT * FROM menus_show WHERE id = $meal2 ;");
while($row = mysql_fetch_array($result))
{
$image = $row['imagesmall'];
$title = $row['title'];
$description = $row['text'];
}

}

session_unregister('$order');


$orderw2 = unserialize($_SESSION['orderw2']);

$array = $order->getData();
$meal1 = $array[0];
$meal2 = $array[1];
$meal3 = $array[2];
$meal4 = $array[3];
$meal5 = $array[4];
$meal6 = $array[5];
$meal7 = $array[6];




include('config.php');
$link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die("Could not connect: " .
mysql_error());
mysql_select_db("_simp");
if (isset($meal1)){
$result = mysql_query("SELECT * FROM menus_show WHERE id = $meal1 ;");
while($row = mysql_fetch_array($result))
{
$image = $row['imagesmall'];
$title = $row['title'];
$description = $row['text'];
}
}
<?
if (isset($meal2)){
$result = mysql_query("SELECT * FROM menus_show WHERE id = $meal2 ;");
while($row = mysql_fetch_array($result))
{
$image = $row['imagesmall'];
$title = $row['title'];
$description = $row['text'];
}


}

Link to comment
Share on other sites

Not really

 

PHP 6 does fix this however it'll be sometime till we solidify how to and when to pass objectives via sessions.

 

 

You should be able to rebuild your objects for the load from your database on each load via the PK being stored in a session.

 

 

 

However Like I said php 6 is changing the norms and this may be come the preferred way to handle objects.

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.