Try putting as much effort into your posts as you would like to see in the responses.
Your habit of making single-word and incomplete-sentence posts does not make people want to spend their volunteer time to help you if you won't even take the time to form complete sentences.
(On a cultural note, that's a reasonable response in Hindi, but comes across a little weird in English.)
A cookie can only have a single value, and as mentioned, needs a round-trip.
If you're trying to keep user-specific objects, keep them in the session.
I'd really recommend getting familiar with how HTTP, web applications, etc. work before trying to go much further, and Bear is correct-it's a good idea to really make sure your messages are as clear and concise as possible, but not so concise that they sound dismissive, or trivialize the amount of time people are putting in to helping you. Thanks!
deep raj
Ranch Hand
Joined: Dec 11, 2009
Posts: 186
posted
0
i want that whenever anyone signup his user name is saved in cookie that's why i used this in user_regis.jsp page
Cookie ck2=new Cookie("cookiee",s3);
response.addCookie(ck2);
now when i get the value from cookie it does not give all values of users that are signed up
this is the problem'
can anyone give me the solution?
thankx in advance
Cookies are local to a single machine--if you want to store the names of all people that are signed up you'd need to collect them on the server side during the login process. And again, I strongly recommend taking a step back and trying to understand the nature of Java web applications before proceeding much further--it will save you untold headaches and frustration.
deep raj
Ranch Hand
Joined: Dec 11, 2009
Posts: 186
posted
0
i know that cookie is stored on local machine saved in browser
i want to create it for change password coding
if anyone use my username and get password from change password link then he will be able to see my profile
i want to remove it
so i create coookie
when person gets login with my username/password at another machine ,then he would be not eligible
because cookies are available only my pc.
so can anyone solve me this problem
Maybe try listing specifically the steps you think you'd need to take in order to implement this--think through the problem, post your potential solutions, we can take it from there. You already know that you want a cookie (probably set on login and removed on logout) and that you need to track those on the server side.
How might you implement that?
deep raj
Ranch Hand
Joined: Dec 11, 2009
Posts: 186
posted
0
should i not use cookies in change password concept
David Newton wrote:Maybe try listing specifically the steps you think you'd need to take in order to implement this--think through the problem, post your potential solutions, we can take it from there. You already know that you want a cookie (probably set on login and removed on logout) and that you need to track those on the server side.
How might you implement that?
But you didn't do what I asked, which is to write down the exact steps, in English (NOT code), that you'd need to take in order to solve this problem.
deep raj
Ranch Hand
Joined: Dec 11, 2009
Posts: 186
posted
0
1. i create sign up page in which form action is regis.jsp
2. in regis.jsp database insertion takes place
3. in regis.jsp i also create cookie when i store that people user name
4. in login.jsp when person click on change password link it must be cheked that the people user name is available in cookies or not
5. if not means that people has fake login
problem is that all people that are signed up has username values and that values must be stored in cookies
while it stores only latest person usermname
The links were provided in an attempt to explain to you how JavaRanch works, and why you're getting the answers you are instead of someone here doing your work for you. So no, they're not directly related to your question--but they *are* related to the interactions between us (the JavaRanch "staff") and you.
The next step in solving your problem is deciding how to use that list of currently logged in users. (You'll also need to remove users from that list if they log out or if that session expires.)
Since you're specifically trying to exclude the same user ID from logging in from a different *machine* at the same time they're already logged in, your problem is actually more complicated than you might have thought at first--what if I try to log in using a different browser on the *same* machine? We'll cross that bridge later. (It's also not clear how you'll handle a case when the user has cookies turned off--also a task for another time.)
So when a user logs in, you'll give them a cookie, and mark them as being logged in by storing their user ID in the "logged in list". What's next?
deep raj
Ranch Hand
Joined: Dec 11, 2009
Posts: 186
posted
0
List users=new ArrayList();
Cookie passwd=new Cookie("user",users);
response.addCookie(passwd);
this is written in login.jsp page
now when we add username in cookie i write this
users.add(s3); //in s3 there is username
is it correct way?
1) What's your definition of a cookie?
2) Where does cookie data reside?
3) What kind of data can a cookie hold?
Here's the solution I think you're trying to use:
1 User logs in
1.1 Store user name on server side
1.2 Give user a cookie saying they're logged in
2 Another user logs in
2.1 Is that user already logged in?
2.2 If yes, signal error
2.3 If no, continue normally
3 User logs out
3.1 Remove their name from the list of logged in users
Is that correct, more or less? If so, which specific part are you having a problem with? If not, tell me what your ideas are, and we'll go from there.
(Noting that there are still a couple of issues with this solution that are probably not worth solving, given the nature of web applications and how HTTP works.)
deep raj
Ranch Hand
Joined: Dec 11, 2009
Posts: 186
posted
0
difficulty is at-store user name at server side
is there separate cookies given to each user OR a single cookie store all users
Keeping a list in the application context is probably the easiest solution. You could also persist currently-logged-in info to a database, but that might be overkill--I have no idea what your capacity requirements are.