Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fgn's avatar
Level 1

use temporarySignedRoute in redirect with old DateInterval

Hi, i got an temporarySignedRoute. With this url the user can see a form and can send the form. After sending the form i want to redirect the user to the form again with the old "url" so that i don't create a new url with a new Lifetime.

What is the Best way for it?

0 likes
3 replies
tisuchi's avatar

@fgn I can think this way:

Here is an example of how you might use the temporarySignedRoute method in a controller to redirect the user to a form after they have submitted it:

public function processForm(Request $request) {
    // Process the form data
    // ...

    // Create a temporary signed route with a lifetime of 5 minutes
    $lifetime = new DateInterval('PT5M');
    $url = route('form', [], false)->temporarySignedRoute($lifetime);

    // Redirect the user to the form with the temporary signed route
    return redirect($url);
}

In this example, the processForm method processes the form data and then generates a temporary signed URL for the "form" route, with a lifetime of 5 minutes. The user is then redirected to this URL.

Note that, the route should be defined with ->name('form') and you should pass the third parameter in route function as false, that is route('form', [], false) to not create a new url with a new lifetime.

1 like

Please or to participate in this conversation.