Web Developer
It shows Session is not valid. I am using SSR login.
If if set table permission User(Read) then realtime can not show update. But if I set table permission Any(Read) then realtime can show update.
** Login function**
"use server"; try { const { account } = await createAdminClient(); const session = await account.createEmailPasswordSession(email, password); const isVerified = await auth.isVerified(session.secret); if (!isVerified) { await auth.sendVerifyEmail(session.secret); await auth.logout(session.secret); return { error: "Email not verified! A new link has been sent to your email.", }; } (await cookies()).set("session", session.secret, { httpOnly: true, sameSite: "strict", secure: true, expires: new Date(session.expire), path: "/", });
const jwt = await auth.setJWT(session.secret); (await cookies()).set("jwt", jwt, { httpOnly: false, sameSite: "strict", secure: true, maxAge: 60 * 15, path: "/", }); return { success: true, }; } catch (error) { console.log("Error in login......", error); return { error: error.message }; } },```
> **Client Side code**"use client";
import {useEffect} from "react";
import Cookies from "js-cookie";
import { client, account } from "@/lib/appwriteWeb";
export default function ToDoList() {
useEffect(() => {
const getUser = async () => {
const jwt = Cookies.get("jwt");
client.setJWT(jwt);
const user = await account.get();
console.log(user);
client.subscribe("databases.db1.tables.todolist.rows", (event) => {
console.log("Realtime is working ", event);
});
};
getUser();
}, []);
}