one site ,open two browser with two accounts ,interchanging the data ,how to avoid this?

Hi,
I've a problem with my https site,if two users opened in the two different browser windows in the same machine the second entered data got over ridden with older one,i am setting a secure cookie in my servlet because i 've to have cookie,how we can avoid the second user will not get the first users data?Right now i put a check in the Login servlet to check whether it has any cookie ,force the user to close the browser and open a new one,the need is we want both the users will be alive with their data.
if you need more info please let me know.
Thx
sethu
sethupathiAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
You need to login the different users from different browser processes, and not two browser windows from the same process. All windows for the one process  (in IE, NS at least) share the same cookies, and thus the same session if you are using cokkies for session management.

If you use URL rewriting on the other hand for maintaining session then each window will have it's own session.
0
 
sethupathiAuthor Commented:
This is some what difficult situation so its really appreciated if i get answer.
0
 
wide_awakeCommented:
How can two different users open two different browsers on the same machine at the same time?

Maybe I don't understand your question properly...
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sethupathiAuthor Commented:
ok. one user has two accounts with my site ,he opened one window with his first username,open the second window and log in with second username ,now if goes back to first window and try to go some other link he is getting the second user name's information ,the cookie which was set to the first one was over ridden with second one,the question is how we can keep the same cookie for each user?here i am setting only tmp cookie once the browser closed the cookie will be gone,now you go thru the first mail probably will give you good understanding.
if you need some more let me know
Thanks for immeadiate response, i've a hope once i was got back by you.
Thanks
sethu
0
 
girionisCommented:
> How can two different users open two different browsers on the same machine at the same time?

  Exactly!!!
0
 
girionisCommented:
 How are you setting the cookies? Does each cookie contains unique information or do you have the same information in both cookies?
0
 
igor_skCommented:
There is only one instance of servlet class regardless of number of connected users.

When your firts user connect you, probably, store some of his data in Login servlet object data. When second user connects, the same Login servlet object instance is used. Therefore, the second user will see first user's data.

If you need to store some user's data for future use you can store it in corresponding HttpSession object:

session.setAttribute(java.lang.String name,
                     java.lang.Object value)

You can use session.getAttribute(java.lang.String name) method to get this data later.
0
 
wide_awakeCommented:
Can you (a) set the cookie filename?  Or (b) the location of the cookie file?  If either of those are possible, you can do (a) set the cookie to be username.txt, or (b) <cookiePath>/username/cookie.txt

-Mark.
0
 
JituCommented:
Since you are setting the cookies yourself, wide_awake has suggested a good solution.

Listening...
0
 
girionisCommented:
 I do not think there is a need to set the cookie filename, just set different unique information in the cookie. Username would do. Then check all the cookies the browser returns with each request against the username of the user logged in.
0
 
wide_awakeCommented:
If the cookies from the site always had the same filename, you'd end up with the same problem.  When the 2nd user logged in, it'd overwrite the first user's cookie, then both users would be pointing to the same data (2nd user's).

Different filenames are a good way to encapsulate all the info.
0
 
girionisCommented:
 The cookie always has the name you give it therefore if you give it different name (lets say the username in our case) then you can distinguish between cookies since you will only look for the cookie that its name matches the username of the user logged in.
0
 
CleanupPingCommented:
sethupathi:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
jimmackCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept objects' comment as answer.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jimmack
EE Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.