ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 17th, 2003, 09:12 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Thumbs up Any body can tell me how to use array in the session?

I wanna develop a asp page to store some filepath string in the array of string,but i don't know how to save the array into the session,and how to read out it from the session?...Any body can tell & help me??..
__________________
Being a Code Headman !

Reply With Quote
  #2  
Old October 17th, 2003, 02:27 PM
aspman aspman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Ashburn,VA
Posts: 105 aspman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 22 m 40 sec
Reputation Power: 6
as you store any other session variable. there is no much difference in using an array as a session variable.

just do

dim arr(0,2)
arr(0,0)=1
arr(0,1)=2

session("arr")=arr

Response.Write "session array is " & session("arr")(0,0) & "<br>"
__________________
If you ask a question you are a fool for a second. But if you dont ask, you are a fool for a life time.

Reply With Quote
  #3  
Old October 19th, 2003, 09:02 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Thx very much for aspman!This reply is important for my devlope.

Reply With Quote
  #4  
Old October 19th, 2003, 07:14 PM
televisi televisi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 televisi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You said:
=======
Response.Write "session array is " & session("arr")(0,0) & "<br>"
=======

Can I use a variable to store the session array?, I tried it but not working, any idea?

what I tried to do:
- I make an array in 1st html and put them into session
- I open 2nd page (through submit declaration or HREF), and want to retrieve that 1st stored session

1st HTML
=======
dim arr(0,2)
arr(0,0)=1
arr(0,1)=2
Session("array") = arr

2nd HTML
=======
dim arr2(0,2)
arr2 = Session("array")

so that I will be able to
response.write(arr2(0,1))

instead of
Session("array")(0,1)

Do you get what my idea is?, any idea to work them out?

thank you

Reply With Quote
  #5  
Old October 19th, 2003, 10:27 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
televisi!U can't assign array variable to another array variable..U can assign each member of a array variable to the memer of another array!

Like it:
for i=0 to 2
arr(0,i)=session("array")(0,i)
next

Reply With Quote
  #6  
Old October 22nd, 2003, 10:01 AM
televisi televisi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 televisi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thank you very much

Reply With Quote
  #7  
Old October 22nd, 2003, 01:20 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,957 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 15 h 35 m 19 sec
Reputation Power: 802
I don't have any problems assigning an array to a different array in IIS5.1 on XP Pro

The following test code works fine on my box, with arr2 being a clone of arr1 when done.

Code:
<%
Dim arr1(1,1)
Dim arr2
arr1(0,0) = "test1 0,0"
arr1(0,1) = 4
arr1(1,0) = "test1 1,0"
arr1(1,1) = 8
'
arr2 = arr1
%>

Reply With Quote
  #8  
Old October 22nd, 2003, 08:33 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Oh!Doug G,his problem is assign a array from a session array object(not a array).Maybe u don't understand his problem.

Reply With Quote
  #9  
Old October 22nd, 2003, 10:24 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,957 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 15 h 35 m 19 sec
Reputation Power: 802
There is no problem storing an array in a session and assigning the array to a new local variable copy on another page in the same session.

televisi, the only thing I see in your code that may be causing you a problem is in the 2nd page where you dim the arr2

dim arr2(0,2)

Try just

dim arr2

There is no need to iterate through the array elements to copy an array out of a session variable to a local variable.

Reply With Quote
  #10  
Old October 23rd, 2003, 09:11 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
THx Doug G!But can u tell me some thing about your way or viewpoint..

Reply With Quote
  #11  
Old October 23rd, 2003, 02:45 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,957 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 15 h 35 m 19 sec
Reputation Power: 802
I don't think much has changed with asp.NET but I'm using asp3

Session is basically a collection object capable of storing any datatype or object at any named node.

So if you have a local array variable, you can simply use Session("theArray") = localArray to store the array in the session object.

Then on any subsequent page in the same application with the same Session, you can simply use localArray2 = Session("theArray") to copy the previously stored array to a new local variable.

I don't ever try to reference a single array node in an array stored in a session myself, I will always copy the array to a local variable before working with it.

Reply With Quote
  #12  
Old October 23rd, 2003, 08:18 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Thx for your detailed introduce!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Any body can tell me how to use array in the session?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |