Back

[SOLVED] How to login and create a session

  • 0
  • Accounts
  • Web
IsItBathTime
4 Jul, 2023, 20:26

Maybe I'm not storing the session ID in cookies after login. Is there an extra step I need to do for this?

TL;DR
The user had questions about login and creating a session. They received advice on using the client and making API calls client-side. They also received suggestions on using server-side rendering and JWT tokens for server-side actions. The user expressed confusion about server vs client-side and received reassurance that they can continue with client-side rendering. They were reminded to prioritize security and offered to share their progress with the community. They also asked about adding middleware for route protection and were informed that SSR has limitations but will be improved in the future. The user expressed gratitude for the help and stated their intention to create a video about their experience with Appwrite.
Drake
4 Jul, 2023, 20:27

Is this code executed client side or server side?

IsItBathTime
4 Jul, 2023, 20:27
IsItBathTime
4 Jul, 2023, 20:27

Server side I think, using +page.server.ts on sveltekit

D5
4 Jul, 2023, 20:27

Then that's the problem

D5
4 Jul, 2023, 20:28

You will need executing it client sided to get a session

IsItBathTime
4 Jul, 2023, 20:28

Okay this is helpful I'll try working this out with this new information 😊

IsItBathTime
4 Jul, 2023, 20:29

Sorry for the silly questions this is my first project

Drake
4 Jul, 2023, 20:32

Not silly at all! SSR is tough right now and we're planning on improving the experience there

loup
4 Jul, 2023, 20:34

I guess without SSR there is no way to add middlesware to protect route (if not authentificated) ?

loup
4 Jul, 2023, 20:34

welcome to the team πŸ˜΅β€πŸ’«

IsItBathTime
4 Jul, 2023, 20:40

Thanks, I would try and post a video about my experience using appwrite as a first time web creator once I get to the end πŸ˜…

loup
4 Jul, 2023, 20:44

I'd be curious to see if you're having the same issues

D5
4 Jul, 2023, 20:45

If you still need for any reason server side rendering, the best way to go is probably by sending to the server a Jwt token. In other words you perform things like login/signup client side and then any other things, server-sided. If the page doesn't needs SEO (for example, a dashboard, a chat like WhatsApp, etc), or it just really doesn't needs SSR, since most things are changing dynamically, then just go with client side rendering, probably it will be easier

IsItBathTime
4 Jul, 2023, 20:45

I'll see what happens, once it's all working I'll share the git so the community can correct any security issues I may have made 😁

IsItBathTime
4 Jul, 2023, 20:46

Thanks I'll attempt to get this working on the client side

loup
4 Jul, 2023, 20:51

but for example I have profile user page like mywebsite.com/@amesky , and I wanna add in the metdata description (which is a server component only), data of the user, how can I get the data in server side with APpwrite ?

loup
4 Jul, 2023, 20:52

That why Im a little bit confused with the notion of server and client side

loup
4 Jul, 2023, 21:41

damn im stupid forget what ive said APPWRITE IS AMAZING

IsItBathTime
4 Jul, 2023, 23:42

You are right about the cookies, it seems to he sending the session ID to local storage instead instead labeled cookie fallback

IsItBathTime
4 Jul, 2023, 23:42

Any suggestions on how to resolve this

IsItBathTime
4 Jul, 2023, 23:48

I'll do some research and work this out, thanks I understand the problem now and I can see what's going wrong

Drake
5 Jul, 2023, 01:52

That's a fallback system when you don't have domain set up for cookies. Ideally, you'd be making API calls client side and your Appwrite endpoint is a sub domain of your app's domain

IsItBathTime
7 Jul, 2023, 19:44

Thanks I got it working using the client 😊

Drake
7 Jul, 2023, 19:51

[SOLVED] How to login and create a session

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more