@Chop As soon as a request goes through the Laravel middlewares and stuff, it is stored in the session as the "current URL", hence being the previous on your session.
You get /photos, now it's the previous URL (/photos), it that page, you call /photo/152 and return a response (you call it with the src="" attribute of the image, browser does it automatically. Laravel stores that as current URL, because it doesn't know if it's a page or anything else, for Laravel, it's just a response, whatever it is. Previous URL is now /photo/152 in the session. It's actually normal.
The request goes through the Illuminate\Session\Middleware\StartSession middleware. This in turns initializes the session interface and stores the current URL: $this->storeCurrentUrl($request, $session); This method in turns does this:
protected function storeCurrentUrl(Request $request, $session)
{
if ($request->method() === 'GET' && $request->route() && !$request->ajax()) {
$session->setPreviousUrl($request->fullUrl());
}
}
setPreviousUrl in \Session just puts the key _previous.url in the session.
I'm NOT sure, but you can try in your /photo/152 controller method to do this:
Session::setPreviousUrl(Session::previousUrl());
(Of course I'm using fake routes etc)
EDIT: DebugBar updates itself with every request, you get a dropdown in the top right of it, showing every request. Session::previousUrl() is echo'ed in the page directly and not updated when you call the image, so that's why.