yii calls unrequested action before requested one

Hello

I can explain the situation easily with a scenario:

i have a controller and two actions in it.

these two actions renders different views.

i set a session variable, which affected by a parameter, in first action. I want to use it in second action but when i call second action many times this session variable changes despite not calling first action.

i made a test which made me surprised.

At first i called first action and then called second action. Everything was fine. After that i changed the declaration of the session variable and saved.

After making requests to second action, i saw the value that i saved.

I searched a little bit about that but i couldn’t find anything and i don’t have a lot of time.

Thank you for your interest

operating system: Ubuntu Linux

Server version: Apache/2.2.17 (Ubuntu) PHP Version 5.3.5-1ubuntu7.10

browser: firefox, chromium

Yii Framework/1.1.10 2012-08-02 18:15

Hello,

If you haven’t a best guess yet, maybe you could post the relevant parts of your code?

Cheers :)

Actually i couldn’t repeat same issue in a fresh yii webapp.

In my app:

I have ProductController with actionList and actionDetails in it.

There are 4 product categories. User see all of the products at first and then category can be selected. when category is selected, i list products in that category.

After listing products user clicks one of them and details page shows up. There is a feature that user can go next and previous product in details page but it should be in the order which has been seen in the previous product list. So if user hasn’t selected a category, this queue can contain all productids but if a category has been selected, then the queue should just contain this category’s productids.

I select products from database in order and show them in list page and i do not want to do it in details page again.




actionList

{

	if(isset($categoryid) && is_numeric($categoryid))

		$products = Product::model()->findAll(

						array(

							'order'=>'enddate DESC', 

							'condition'=>'kid=:categoryid AND enddate>now()', 

							'params'=>array(':categoryid'=>$categoryid))

						);

	else

		$products = Product::model()->findAll(

						array(

							'order'=>'enddate DESC', 

							'condition'=>'enddate>now()')

						);

	$session=new CHttpSession;

	$session->open();


	$productids = array();

	foreach($products as $product)

		array_push($productids, $product->Id);

	$session['productids'] = $productids;

}


actionDetails

{

	$session=new CHttpSession;

	$session->open();


	$next_productid = null;

	$prev_productid = null;

	$productids = $session['productids'];

	$first_productid = end($productids);

			

	while ($id = array_pop($productids))

	{

		if($id == $productid)

		{

			$next_productid = array_pop($productids);

			if($next_productid == null)

				$next_productid = $first_productid;

			if($prev_productid == null)

				$prev_productid = reset($productids);

			break;

		}

		else

			$prev_productid = $id;

	}

}



Thank you