Register  |  Login

Question Details    

   Question

Time: 14:24 - Jul 12, 2006     Asked by: aopk2002      Status: Answered      Points: 25   

Can I strore arraylists in cookies or someotherway?

I'm doing a room reservation website and I have implemented 3 arraylists that contain the clients room types, room number and total price. I pass these arraylists to 3 other static arraylists in an AppCode class. I made those static since that's the only way to keep the values in there. My problem is that this works for a single browser, but whenI try with multiple browsers, and insert data into any of the arraylists, bcos they are static they affect other client browser requests.
I need to know how I can prevent this or another method of passing arraylists to other web forms taking note of sessions.

Thanks in advance.
Kobi

Ask a New Question

Become a Quomon Expert

Current Categories

 

Other Questions Needing Answers


   

Answer Discussion
Answer Discussion
Answer Summaries
Answer Summary
 
First of all, what programming language do you use? .Net? Java? What environment? ASP?

I can give you an answer for .Net. You have three areas in .Net where you can save information: Viewstate, Session State and Application state. Depending on where and how you want to use the information you select the correct area.

Viewstate:
information is available for the same webpage. Example, you load data into a drop down field and want to load it only once for this page. You enable viewstate for the drop down component and it keeps the data between posts

Session state:
you want to have data available for the same session but across different web pages/forms. You can save almost anything which is serializable to Session state. And session state can be held in memory of the web server, on another state server or even in a database. Key is the session ID

You create a new entry in session state in C# with:
String[] MyArray;
//Fill array or do something
Session["MyArray"] = MyArray;
You retrieve Session state data with
AnotherArray = Session["MyArray"];

Application state:
If you want to make data available across sessions. I.e. global data for every user!

Note, Application State has to be initialized before you can use it. Best place to do thi sin an ASP.Net app is in the ApplicationStart Event.

You create Application state with
Application["AppCount"] = 0;
You can then use Application["AppCount'} on every page in this application. Across sessions and users!

Let me know if you need more information

Cheers

Peter

Expert:

PeterNZ

Date:

Jul 12, 2006

Time:

22:23

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Thanks Pete. I happened to have bumped into the solution yesterday, that i could use ASP.NET's Session[] class to store my arraylists and retrieve them by casting the Session variable as an arraylist. It works now. However have you tried using the HttpCookies class? It seems that b'cos of the size limitation imposed when using client cookies, Errors are flagged when you try to store a cookie with the HttpCookie class. I could be wrong, but that's my observation. Anyway lessons learned and Thanks a lot for the help.

Expert:

bugzilla

Date:

Jul 14, 2006

Time:

14:23

 

Votes: Good (0) | Bad (0)
Login to rate this answer

aopk2002, please close this question and distribute the points.
If you didn't get a solution to your problem or you found it yourself, please leave a comment here to let the experts know.
Thanks,
Quomon Admin

Expert:

admin

Date:

Jun 06, 2007

Time:

06:59

 

Votes: Good (0) | Bad (0)
Login to rate this answer

The question has been closed.

Quomon Admin

Expert:

admin

Date:

Jun 16, 2007

Time:

15:51

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Question Answered

This question has been answered, and points have been rewarded to the following experts:

PeterNZ: 15
bugzilla: 10

You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.

 
No summaries have been submitted yet. Want to be the first?



Respond to this question:

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

 

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

   

"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it


All Questions


Language Options

English:

www.quomon.com

Español:

www.quomon.es

Quomon Blog

blog.quomon.com

Sponsors

Questions and Answers Software
Real Estate Postcards
Marketing Fulfillment