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
https://forums.phpfreaks.com/topic/133822-sessions/
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
https://forums.phpfreaks.com/topic/133822-sessions/#findComment-696475
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.