473,394 Members | 1,709 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,394 software developers and data experts.

Accessing sessions in loop:

Hello,

Could anyone advise, if I had three sessions as below, is there anyway
I could access the three in a loop.

$_SESSION['item1'];
$_SESSION['item2'];
$_SESSION['item3'];

Thank you
Jul 17 '05 #1
4 1750
Antoni wrote:
Hello,

Could anyone advise, if I had three sessions as below, is there anyway
I could access the three in a loop.

$_SESSION['item1'];
$_SESSION['item2'];
$_SESSION['item3'];

Thank you

You cannot have 3 sessions, you can only have one session. You have 3
session variables there and yes you can access them in a loop.

And your question makes no sense?
Jul 17 '05 #2
Antoni wrote:
Hello,

Could anyone advise, if I had three sessions as below, is there anyway
I could access the three in a loop.

$_SESSION['item1'];
$_SESSION['item2'];
$_SESSION['item3'];

Thank you

<?php
for ( $i = 0; $i++; $i <= 3 ) {
echo $_SESSION['item' . $i];
}
?>

--
Pieter Nobels
Jul 17 '05 #3
Antoni wrote:
Hello,

Could anyone advise, if I had three sessions as below, is there anyway
I could access the three in a loop.

$_SESSION['item1'];
$_SESSION['item2'];
$_SESSION['item3'];

Thank you


foreach($_SESSION as $key => $value){
// do things
}

or

for($i = 1; $i <= 3; $i++){
$var = $_SESSION["item$i"];
}

--
Elliott C. Bäck
http://elliottback.com
Jul 17 '05 #4
"Pieter Nobes" <pi******@MOVE.opengate.be> wrote in message
news:7q***********************@phobos.telenet-ops.be...
Antoni wrote:
Hello,

Could anyone advise, if I had three sessions as below, is there anyway
I could access the three in a loop.

$_SESSION['item1'];
$_SESSION['item2'];
$_SESSION['item3'];

Thank you

<?php
for ( $i = 0; $i++; $i <= 3 ) {

[...]

The $i must = 1 not 0.
Jul 17 '05 #5

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

Similar topics

8
by: ndsoumah | last post by:
hello guys I'm trying to get access to variables I put in a session variable from another page and it fails... here's the exact situation main file page1.php
1
by: Tony Pryor | last post by:
Hello, Anyone know if running two client telnet sessions at the same time should be an inherent problem? They don't seem to want to share a port or are they trying to use the same console for...
2
by: George Grodentzik | last post by:
I created a typed dataset from which I am trying to access the data. When I use the following code to access a row string name =dataset.person.firstName I receive an error...
5
by: David P. Donahue | last post by:
Is there a way to iterate through some kind of collection and access session variables in current active sessions on the website? For example, I'd like to add a feature to an administrative...
3
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object...
3
by: niju | last post by:
Hi there, I have three web pages (A,B,C). I need to prevent users accessing page B and C without accessing A. What would be the best way to achieve this rule? Many Thanks Niju
0
by: Benny Hauk | last post by:
I'm trying to find a way to monitor all active sessions from a single, administrative page. It would be an administrative page for me to see the number of sessions, and the contents of those...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
2
by: brendan_gallagher_2001 | last post by:
HI I am developog an ASP.net site (using vb.net 1.1) which will be accessed by a number of different office locations, where certain users will be assigned a authoriser profile, and others will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.