You are here: Re: Access $_SESSION values via an index instead of a name « PHP Programming Language « IT news, forums, messages
Re: Access $_SESSION values via an index instead of a name

Posted by David Haynes on 03/02/06 04:17

Chuck C wrote:
> Is there a way to access the values from a session by using an index/count
> instead of the name?
>
> Something like:
>
> $_SESSION[1]
>
> Also, can you query the name and value for this?
>
> What I am looking to do is have a lot of different variables stored in my
> session but the names may change or be different.
>
>
I just had to do something similar like this:

$good = array();
foreach( $_SESSION as $key => $value ) {
switch( $value ) {
case 'good1':
case 'good2':
case 'good3':
$good[] = $value;
break;
default:
unset($_SESSION[$key]);
}
}

Not the prettiest, but it got the job done.

-david-

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация