0

I'm making an application with web services and i want to memorize username and password of user in cookie and then i want to resume the username and password of the user in another web service

NewCookie cookie = new NewCookie(new javax.ws.rs.core.Cookie("cookie", (username+password).hashCode()+""), "", 15*15, false);

in this line of code i create the cookie but I can't take the values ​​in another web service

I'm new to java programming, help me!

1 Answers1

0

You shouldn't store a user name or password let alone both into a cookie as a cookie can be easily read. Instead you should look at using a JWT or similar.

Checkout https://jwt.io

As for your question it looks like you're using Jersey in which this: How to set cookie in Jersey? should answer your question. Note you set a cookie with a Response!

Jwilz
  • 54
  • 4
  • ok but i don't know how to implement it.. can you take me an example? –  Jan 15 '19 at 07:51
  • Implementing a JWT or the cookie? If its for the cookie, the link to a previous question shows you a code snippet at how to set a cookie on the client's browser by issuing it in a response. – Jwilz Jan 15 '19 at 08:43