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

declaring array as a session variable

Hello all,

I want to pass the array from one php page to other php page. So how to make array as an session variable.

with regards
Aug 22 '07 #1
5 2022
nathj
938 Expert 512MB
Hello all,

I want to pass the array from one php page to other php page. So how to make array as an session variable.

with regards
Hi kumuda v

I think you can simply do the following

Starting Page
[php]
<?php
session_start() ;

// assuming array is defined as $laArray for simplicity

$_SESSION['my_array'] = $laArray ;

?>
[/php]
Target page:
[php]
<?php
session_start ;

$laArray = $_SESSION['my_array'] ;

// you can now use $laArray in whatever wway you wnat

// write it back to the $_SESSION
$_SESSION['my_array'] = $laArray ;
?>
[/php]


This should do the trick for you. I'm not sure if it is possible to manipulate the array within the $_SESSION array - it should be, but I would find that confusing so I would always extract it first for clarity in code.

I have not tried this idea but I think it should work. Have a go and ost back with any problems - be sure to load code into code tags.

Cheers
nathj
Aug 22 '07 #2
pbmods
5,821 Expert 4TB
Heya Kumuda.

Have a look at these articles:
The Array Type
External Variables
Aug 22 '07 #3
pbmods
5,821 Expert 4TB
Merged duplicate posts.
Aug 22 '07 #4
Thank you,
I got the solution for that.

With regards
Aug 23 '07 #5
pbmods
5,821 Expert 4TB
Heya, Kumuda.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 23 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Colin Steadman | last post by:
Hope this makes sense! I'm building an ASP page which allows uses to add items to an invoice via a form, ie: Item No Part No Order No Quanity Units Price VAT ------- ...
29
by: Friday | last post by:
Sorry if this is the wrong group. I tried to find the one I thought would be most relevant. I'm an old PHP guy, who knows little about asp and NOTHING about asp.net, but need to learn at least...
3
by: Neil Jarman | last post by:
Hi, I need to create an array with a session variable. According to thebook I'm using, the following should work, but if fails: for each key in request.QueryString if left(key,6) = "cboRun"...
3
by: klynn | last post by:
I defined a session variable as an array using Session = new string; Later, in my code, I need to set it and sort it. I tried Session = "some string"; My error is "Cannot apply indexing with to...
3
by: Brad | last post by:
I am storing an array which contains about a dozen chracter items to a Session variable. Later, I need to use this array so I am doing the following: Dim eventTypes As String() =...
5
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers? Reference...
4
by: MrBiggles | last post by:
Here's the sitch: I read in a csv file with 60000 lines (20 fields per record), and store the data to a local array. The file is read in and stored just fine and pretty quick. Now, if I try to...
5
by: juan | last post by:
Hello, I have a web project in Visual Basic 2005. I want to create a session variable in the "global.asax" file as an array of strings type. The syntax I use is the following: ...
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte()...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.