Session problem

They have: 2 posts

Joined: Apr 2004

Hi!

I have a form with a list of items and I created a series od checkboxes that are bounded to the ID number of the database table.

I created a session to store all the selected items and I can forward the values to the following pages with no problem.

My issue is that if I return to that page and check some other itens and send them to the next page I overwrite the existing values of the session and I need to concatenate them. Confused

For example

1st time I submit I have: 1,2,7
2nd time I submit I have: 3,5
....

I need the final value to the session to be: 1, 2, 7, 3, 5

Is this possible? How? I am completely lost here!

Thank you!

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I assume you're using PHP?

You can check to see if there are any values in the session first, if there are, then .= to the session, else, write the session.

I think a better approach, now that I've typed that out, would be to check to see if there are any values in the session. If there are, then automatically check those options.

Then you would resubmit the page and over-write the session without losing any data. That would give you 1,2,3,5,7 as a result.

They have: 2 posts

Joined: Apr 2004

Hi!

Sorry forgot to say I am using ASP!

Thank you!

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Okay, then I'm out of my area of expertise on the particulars, but in general you can check whether the session has content, then display the form with checked boxes if it does and not if it doesn't?

http://www.w3schools.com/asp/asp_sessions.asp seems to cover a lot of the basics for using sessions contextually.

druagord's picture

He has: 335 posts

Joined: May 2003

What you should do is check that the value in the form are checked if they are in the session. in other word you should check the session before displaying the form too. i don't remember the session specifics in asp but that's how i do in PHP the concept is the same

IF , ELSE , WHILE isn't that what life is all about

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.