![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/private_html/src/pages/ |
import { useSession } from 'next-auth/react';
import { useRouter } from 'next/router';
import { useEffect } from 'react';
export default function TestSession() {
const { data: session, status } = useSession();
const router = useRouter();
useEffect(() => {
console.log('Session status:', status);
console.log('Session data:', session);
}, [session, status]);
if (status === 'loading') {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
<p>Loading session...</p>
</div>
</div>
);
}
if (!session) {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-center">
<h1 className="text-2xl font-bold mb-4">No Session Found</h1>
<p className="mb-4">You are not authenticated.</p>
<button
onClick={() => router.push('/auth/login')}
className="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700"
>
Sign In
</button>
</div>
</div>
);
}
return (
<div className="min-h-screen p-8">
<div className="max-w-2xl mx-auto">
<h1 className="text-3xl font-bold mb-6">Session Test Page</h1>
<div className="bg-white rounded-lg shadow p-6 mb-6">
<h2 className="text-xl font-semibold mb-4">Session Information</h2>
<div className="space-y-2">
<p><strong>Status:</strong> {status}</p>
<p><strong>User Name:</strong> {session.user?.name || 'N/A'}</p>
<p><strong>User Email:</strong> {session.user?.email || 'N/A'}</p>
<p><strong>User Role:</strong> {session.user?.role || 'N/A'}</p>
<p><strong>Session Expires:</strong> {session.expires || 'N/A'}</p>
</div>
</div>
<div className="bg-white rounded-lg shadow p-6 mb-6">
<h2 className="text-xl font-semibold mb-4">Raw Session Data</h2>
<pre className="bg-gray-100 p-4 rounded text-sm overflow-auto">
{JSON.stringify(session, null, 2)}
</pre>
</div>
<div className="flex space-x-4">
<button
onClick={() => router.push('/dashboard')}
className="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700"
>
Try Dashboard
</button>
<button
onClick={() => router.push('/user/dashboard')}
className="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700"
>
Try User Dashboard
</button>
<button
onClick={() => window.location.reload()}
className="bg-gray-600 text-white px-4 py-2 rounded hover:bg-gray-700"
>
Reload Page
</button>
</div>
</div>
</div>
);
}