Click to See Complete Forum and Search --> : ASP and session variables?


cusimar9
08-22-2005, 04:30 AM
I'm having a bit of a headache here...

I'm writing an order page where a user can click on various items and add them to a basket

The basket is an array, and I thought I could just handle it with server side vbscript.

However because of the way I've written the page I have to use some client-side processing to get the values, and I can't mix client side with server side vbscript can I?

Can I set session variables in client side vb script? That was my intention but it doesn't appear to work.

Can I store arrays in cookies? How?

Does anyone have any suggestions? I'm a little stumped!

Richard Conyard
08-22-2005, 06:21 AM
You could use cookies, place your array as a comma delimited string and split them on the client side.

That said, what you're upto sounds like a recipe for disaster.

buntine
08-22-2005, 06:50 AM
There should be a way around this. Why is client-side processing mandatory?

cusimar9
08-22-2005, 06:56 AM
Because I have a page with various items. You can select the quanities you want and click one button to 'add to basket'

This requires me to process what's been ordered client side - I can't stick it in the address bar because then if they refresh then they'll order twice as many.

As an aside I've just found out you can't use client side asp with other browsers ie firefox, so I've had to rethink it.

I've had the following idea:

Use Javascript to store them in cookies, then put the list in a comma seperated string and store it in a hidden field in the form. When they submit this I'll be able to process it server side. Its the only way I've though of doing it but it forces me to use Javascript, which I'm not over the moon about...

Richard Conyard
08-22-2005, 06:59 AM
You could always take them to another file when you add the product and redirect them to the page they were viewing afterwards. This would stop any problems with the refresh.

cusimar9
08-22-2005, 07:08 AM
I see what you mean, that would mean I don't have to use cookies...

Richard Conyard
08-22-2005, 07:51 AM
It would mean that you could do everything server side without having to worry about products being added twice.

cusimar9
08-22-2005, 08:49 AM
Great, thanks that's how I've done it

I was really trying to avoid using Javascript but I realised I'm already using it in places and its almost impossible to avoid it completely.

What can you do lol

sajjad27s
08-22-2005, 02:46 PM
You can use arrays or Dictionary object to store items and then assign that to some session variable. Dont mix server side script with client side.