Hi,

I want to get information from each session set, EXCEPT when the session name is 'navigation':
So basically: Create an exception for the session called 'navigation'..

foreach ($_SESSION as $name => $value) 
// $name = navn på session: f.eks. 1 eller 2 - $value indeholder antallet der er i kurven)
{
 if(substr($_SESSION,0,10) != 'navigation') // Doesnt work
   {
	echo $name .' har ' .$value.' varer<br />';
   }
}

How do I do this, without getting the information from the session called 'navigation'?
Regards, Klemme

$_SESSION is an array. Don't you want to check $value ?

foreach ($_SESSION as $name => $value) 
// $name = navn på session: f.eks. 1 eller 2 - $value indeholder antallet der er i kurven)
	{
		if (substr($name,0,5) == 'cart_')
		{	
			echo $name .' har ' .$value.' varer<br />';
		}
	}

This works though.

It is for a shopping cart using sessions - But I have another session declared elsewhere on the site, so I needed to make an exception for that, which my logic screwed up.

I only want to check the sessions named: 'cart_'.

Arh you mean I could just check if $name == 'navigation'{then do something, or not}?

Depends on how you set it. But yes, I think that is what you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.