quarks
quarks

Reputation: 35276

How to implement cookies with GWT?

I have this LoginController in my gwt application which is use to access a login service:

service.connect(username, password);

Once the service succeeds it updates the user model:

model.setCredentials(username, password);

There is a model change listener which fetches other user data from the server when the credential is set, when the gwt application is logged in.

However, my issue is that the login is not persistent, that is the user has to log-in for every tab that is opened.

How can I implement a cookie on my gwt application.

Upvotes: 0

Views: 764

Answers (2)

Colin Alworth
Colin Alworth

Reputation: 18331

It doesn't sound like cookies make sense, if two tabs shouldn't share the same session. Instead, consider some other way of identifying the session to the server, such as appending to the url (see Supporting Sessions Without Cookies in Tomcat), or not using j2ee sessions at all, but having each request authenticate (or offer a token that was received on the first auth).

Upvotes: 0

dimchez
dimchez

Reputation: 2004

You can set a cookie after login using Cookies class, method setCookie. Then after switching tabs check if cookie is set.

Upvotes: 2

Related Questions