Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 25 Time: 14:24 - Jul 12, 2006  

aopk2002

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

Categories

Answer Discussion
Tutorials

 

PeterNZ

Date:: Jul 12, 2006

Time:: 22:23

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

bugzilla

Date:: Jul 14, 2006

Time:: 14:23

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.

admin

Date:: Jun 06, 2007

Time:: 06:59

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

admin

Date:: Jun 16, 2007

Time:: 15:51

The question has been closed.

Quomon Admin

Question Answered

This question has been closed, 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 a Tutorial in the Tutorial Area.

Answer 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:

Forgot Your Password?

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

Answer 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:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10279

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




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



Language Options

English:

www.quomon.com

Español:

www.quomon.es