sessions->driver()->setName($console ? $cookie.'_console' : $cookie); Auth::shouldUse($console ? self::GUARD : self::DEFAULT_GUARD); return $next($request); } public static function isConsole(Request $request): bool { if (self::isConsolePath($request->path())) { return true; } if (! $request->hasHeader('X-Livewire')) { return false; } $snapshot = json_decode((string) $request->input('components.0.snapshot', ''), true); $path = is_array($snapshot) ? ($snapshot['memo']['path'] ?? null) : null; return is_string($path) && self::isConsolePath($path); } /** * Whether a URL of this application is on the console. */ public static function isConsoleUrl(string $url): bool { $base = rtrim(url('/'), '/').'/'; return Str::startsWith($url, $base.self::PREFIX.'/') && ! Str::contains($url, ['\\', '@']); } private static function isConsolePath(string $path): bool { $path = trim($path, '/'); return $path === self::PREFIX || str_starts_with($path, self::PREFIX.'/'); } }