Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Extract session saving to a method #27771

Merged
merged 1 commit into from Mar 5, 2019

Conversation

Projects
None yet
2 participants
@jasonvarga
Copy link
Contributor

jasonvarga commented Mar 4, 2019

This PR simply moves the saving logic into a method so we can override without needing to override the entire handle method.

Our use case:

We have a feature in our app that lets you track how long is left in your session from a specific route.

Every request will add a last_activity timestamp to the user's session.

On one route, we want to check the last_activity timestamp without extending the session (which, normally every request would do).

Our SaveSession middleware would end up looking like this:

protected function saveSession()
{
    if (request()->route()->named('statamic.cp.session.timeout')) {
        return;
    }

    session()->put('last_activity', now()->timestamp);

    parent::saveSession();
}

@driesvints driesvints changed the title Extract session saving to a method [5.8] Extract session saving to a method Mar 4, 2019

@taylorotwell taylorotwell merged commit 1533901 into laravel:5.8 Mar 5, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.