Session variables conflict

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

Hi,

Here's my problem. I'm working on a site where customers can buy
tickets for events. Let's take the example where in webform1.aspx, the
customer enter all its personal information. Then when he clicks a
button to register and go to the next step, i enter the personal
information in the database and redirect to let's say webform2.aspx.

Once in webform2, if the user go back to webform1 with his browser's
back button and clicks on the button in webform1 again, this will add
another record in the database.

To fix this problem i just added the new customer id in a Session
variable when the user registers for the first time. So if he goes
back then clicks on the button again, i will update his profile
instead of creating a new, duplicated record.

However in the admin part of the site, the administrator can create
multiple new registrations at the same time, in different browser
windows. Different windows yes, but still the same session! Which
means that the customer id stored in Session is being replaced.

I'm looking for a way to store the id without conflicts if there are
different windows open for the same session. Is there a way to
retrieve a unique id for each browser window? Ex:

Session[UniqueIdOfWindow.ToString() + "CustomerId"] = 5;


Or any other way to share a value between pages. Hidden fields or
query strings won't work, since this problem happens when the user
clicks on the back button of his browser, so there is no way to send
hidden fields values or parameters in the url. Any idea would be
appreciated. Thanks!

Matt
 
Matt said:
Once in webform2, if the user go back to webform1 with his browser's
back button and clicks on the button in webform1 again, this will add
another record in the database.

Change the code to search for the given client record and update it if
found, insert it if not.
 
Good idea, but won't work if the user go back to correct some
information. Ex: his name or phone number

If he corrects his phone number, and then i do a search using his
phone number, it won't find the record in the database, so i would
create a new record. Thanks for trying!
 
What you need to do is determine what makes a user unique. Is it a Name,
Name / Phone number combination etc. If a combination of all fields make a
user unique, always insert a new record like you are doing. Whatever
happens at step two probably generates some databse entries. You can have a
process that runs daily / weekly that clears out users that "never made it
to step two"

OR

When the user clicks "register" on webform1, check to see if a user like
this exists yet. If it exists, update the user, grab the UserID, and move
on to step 2. If ti does not exists, create the user, grab the UserID, and
move to step two.

Michael

Matt said:
Hi,

Here's my problem. I'm working on a site where customers can buy
tickets for events. Let's take the example where in webform1.aspx, the
customer enter all its personal information. Then when he clicks a
button to register and go to the next step, i enter the personal
information in the database and redirect to let's say webform2.aspx.

Once in webform2, if the user go back to webform1 with his browser's
back button and clicks on the button in webform1 again, this will add
another record in the database.

To fix this problem i just added the new customer id in a Session
variable when the user registers for the first time. So if he goes
back then clicks on the button again, i will update his profile
instead of creating a new, duplicated record.

However in the admin part of the site, the administrator can create
multiple new registrations at the same time, in different browser
windows. Different windows yes, but still the same session! Which
means that the customer id stored in Session is being replaced.

I'm looking for a way to store the id without conflicts if there are
different windows open for the same session. Is there a way to
retrieve a unique id for each browser window? Ex:

Session[UniqueIdOfWindow.ToString() + "CustomerId"] = 5;


Or any other way to share a value between pages. Hidden fields or
query strings won't work, since this problem happens when the user
clicks on the back button of his browser, so there is no way to send
hidden fields values or parameters in the url. Any idea would be
appreciated. Thanks!

Matt
 
Back
Top