Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Persistent cookies / "Remember me"

Antti Kallio
1 decade ago Mar 23, 2009 7:27am
Dmitri Livotov
1 decade ago Mar 23, 2009 7:50am
Jouni Koivuviita
1 decade ago Mar 23, 2009 8:17am
Dmitri Livotov
1 decade ago Mar 23, 2009 8:26am
Antti Kallio
1 decade ago Mar 23, 2009 8:31am
Sami Ekblad
1 decade ago Mar 23, 2009 7:57pm
Antti Kallio
1 decade ago Mar 24, 2009 6:24am
Sami Ekblad
1 decade ago Mar 25, 2009 10:10am
Anonymous Anonymous
1 decade ago Apr 02, 2009 11:55am
Sami Ekblad
1 decade ago Apr 02, 2009 2:20pm
Joonas Lehtinen
1 decade ago Apr 02, 2009 5:56pm
David Wall
1 decade ago Jan 21, 2010 9:59pm
Sami Ekblad
1 decade ago Feb 10, 2010 11:52am
Arthur S
1 decade ago May 26, 2010 2:09pm
Arthur S
1 decade ago May 26, 2010 3:11pm
Sami Ekblad
1 decade ago May 27, 2010 9:11pm
Arthur S
1 decade ago May 27, 2010 9:55pm
Vi Key
1 decade ago Nov 13, 2010 12:13pm
Sami Ekblad
1 decade ago Nov 15, 2010 4:37pm
Vi Key
1 decade ago Mar 01, 2011 3:41am

Hello!
I think that save cookies _only_ on repaint - is no very good idea. In my task, I should save/remove a data (key and value) into cookies without repaint, and I need public methods save and restore cookies. Yes, it is not a bug, but it would convenient? how do you think?

and....
I have exception at cookies.put(cookie[0], cookie[1]); without if(cookie.length >= 2) (with empty cookie value).
this is minor quick fix

@SuppressWarnings("unchecked")
    @Override
    public void changeVariables(Object source, Map variables) {
        super.changeVariables(source, variables);

        if (variables.containsKey("cookies")) {
            reload = false;
            cookies.clear();
            Object variable = variables.get("cookies");
            if (variable instanceof String[]) {
                String[] newCookies = (String[]) variable;
                for (int i = 0; i < newCookies.length; i++) {
                    String[] cookie = newCookies[i].split(VALUE_SEPARATOR);
					if(cookie.length >= 2)						
						cookies.put(cookie[0], cookie[1]);
					else
						cookies.remove(cookie[0]);
                }
            }
            cookiesReadFromClient = true;
            fireCookiesUpdatedEvent();
        }

    }

perhaps it will be useful

Sami Ekblad
1 decade ago Aug 05, 2011 1:45pm

Hi! Included this fix in the 1.0.4.

Last updated on Aug, 5th 2011
Rin .
1 decade ago Aug 06, 2011 3:32pm
Rin .
1 decade ago Aug 07, 2011 5:16pm
Sami Ekblad
1 decade ago Aug 08, 2011 7:38am
Sami Ekblad
1 decade ago Aug 08, 2011 8:01am
Jean-François Lamy
1 decade ago Aug 08, 2011 5:12pm
Rin .
1 decade ago Aug 12, 2011 6:26pm
Gilberto Torrezan Filho
1 decade ago Aug 24, 2011 8:24pm
Sami Ekblad
1 decade ago Aug 30, 2011 12:02pm
Iacopo Pace
10 years ago Feb 14, 2012 11:33am
Iacopo Pace
10 years ago Feb 14, 2012 12:45pm
Dmitry Machin
10 years ago Apr 11, 2012 1:47pm
Sami Ekblad
10 years ago Apr 11, 2012 2:19pm

Hi! First thing that comes to my mind is that did you remember to compile the client-side widgetset? If that is ok, then secondly, are you adding the browserCookies into UI using addComponent? Something like:

cookies = new BrowserCookies();
mainWindow.addComponent(cookies);

Also, I notice that you have made the functions static using ThreadLocal pattern or similar, right? This should work ok, but be careful out there, as the statics are shared among sessions (i.e. users).

Last updated on Apr, 11th 2012
Dmitry Machin
10 years ago Apr 12, 2012 12:25pm
Tudor Raneti
9 years ago Jul 10, 2012 12:43pm
Tudor Raneti
9 years ago Jul 10, 2012 2:01pm