473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Access $_SESSION values via an index instead of a name

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.
--
Chuck C
ElSeeker.at.hotmail.com
Software Developer
Mar 2 '06 #1
2 1631
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 do not see why note -- it is simply an array.

If you are going to have a dynamic amount of keys in your sessions, then
you should put an array inside your session array. Example:
$_SESSION['myarrary'] = array(1,2,3,4);

Carl

--
Carl Vondrick
www.carlsoft.net
usenet [at] carlsoft [dot] net
Mar 2 '06 #2
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-

Mar 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil Powell | last post by:
What is the most standardized method of utilizing the CURL functions in PHP (version 4.3.2) to be able to retrieve the contents of a remote URL that happens to be dependent upon $_SESSION for its...
13
by: Mimi | last post by:
Hello, I am having trouble using the session vars in PHP 4.3.9 OS: Win XP Prof Web Server IIS (is local and there are no links to other servers from the web pages I work on) Browser: IE 6.0 ...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database...
21
by: axlq | last post by:
Someone please tell me if I've discovered a PHP bug. I'm sitting in front of several computers on my home network, behind a NAT firewall/router. I am testing my web site on these different...
1
by: bartdlr | last post by:
Hi, I got a problem to access the $_SESSION variable in my script. I wrote some login code: if the user logs in with his name and password a user object is stored in the $_SESSION variable. ...
2
by: kaotik78 | last post by:
I've racked my head on this all day long. I've been using php for 3 days now and this is the first hang up I've had and it's driving me nuts, but I can't pull myself away from trying to fix the...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.