Project

General

Profile

Actions

Bug #4916

closed

WApplication::changeSessionId() - triggers reload of complete page and session

Added by Matthias N almost 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
High
Assignee:
Roel Standaert
Target version:
Start date:
05/18/2016
Due date:
% Done:

0%

Estimated time:

Description

Wt-Version: 3.3.4

Steps to reproduce:

  1. compile and run example
  2. clear all browser cookies
  3. open page an press "Login"

Behaviour:

After "Login" button has been pressed "Application" text appears and WT will reload the complete page after a short while.

When you press the button again, it works correct (no reload).

Reason:

Wt determine browser cookie support in WEnviroment::ini(). But at this time you have no cookies (see steps 2 of "Steps to reproduce").

WebSession::generateNewSessionId will generate a new session cookie on server side but does not update the cookie on the client side (because WEnviroment::does_cookies_ == false).

Log:

//WApplication::changeSessionId()

[2016-May-18 07:59:34.694016] 4648 [/ D2ZYn6Lf1aqiB6XS] [info] "Wt: new session id for UJqopsgiYqSrDxQC"

[2016-May-18 07:59:34.881216] 4648 - [info] "Wt: session created (#sessions = 2)

[2016-May-18 07:59:34.943616] 4648 [/ VUXTDmcfaZPn0O7P] [info] "Wt: signal from dead session, sending reload.\"

//reload page and session, see WebSession.C:1372 or search for "signal from dead session, sending reload."

Example:

Example.cpp

    #include <Wt/WApplication>
    #include <Wt/WTimer>
    #include <Wt/WText>
    #include <Wt/WPushButton>

    class CSessionApplication : public Wt::WApplication {

    public:
            static Wt::WApplication* CreateApplication(const Wt::WEnvironment& env) {
                    return new CSessionApplication(env);
            }

    private:
            Wt::WPushButton *c_pLoginButton = nullptr;

            CSessionApplication(const Wt::WEnvironment& env) : Wt::WApplication(env) {
                    c_pLoginButton = new Wt::WPushButton("Login");
                    root()->addWidget(c_pLoginButton);
                    c_pLoginButton->clicked().connect(this, &CSessionApplication::buttonClicked);
            }

            void buttonClicked() {
                    Wt::WApplication::instance()->changeSessionId();

                    root()->removeWidget(c_pLoginButton);
                    root()->addWidget(new Wt::WText("Application"));

                    Wt::WTimer::singleShot(100, std::bind([=](){doJavaScript("console.log('test')");}));
            }
    };

    int main(int argc, char* argv[]) {
            return Wt::WRun(argc, argv, &CSessionApplication::CreateApplication);
    }

wt_config.xml

    <server>
        <application-settings location="*">
            <session-management>
                <tracking>Auto</tracking>
                <reload-is-new-session>false</reload-is-new-session>
            </session-management>
        </application-settings>
    </server>
Actions #1

Updated by Koen Deforche almost 8 years ago

  • Status changed from New to InProgress
  • Assignee set to Roel Standaert

Roel, can you check? There is supposed to be always a cookie being creating in JavaScript on the bootstrap script.

Actions #2

Updated by Roel Standaert almost 8 years ago

  • Status changed from InProgress to Implemented @Emweb

Something was going wrong when initializing a session, causing Wt to not update the cookie. I fixed that.

Actions #3

Updated by Koen Deforche almost 8 years ago

  • Status changed from Implemented @Emweb to Resolved
Actions #4

Updated by Koen Deforche over 7 years ago

  • Status changed from Resolved to Closed
  • Target version set to 3.3.6
Actions

Also available in: Atom PDF