<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Theon on Medium]]></title>
        <description><![CDATA[Stories by Theon on Medium]]></description>
        <link>https://medium.com/@theoninau?source=rss-16bd39531245------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*AJMlnPNHO-rrsJ59</url>
            <title>Stories by Theon on Medium</title>
            <link>https://medium.com/@theoninau?source=rss-16bd39531245------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:02:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@theoninau/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Session or JWT: Two ways to implement login, in TypeScript]]></title>
            <link>https://medium.com/@theoninau/session-or-jwt-two-ways-to-implement-login-in-typescript-b96d5996a632?source=rss-16bd39531245------2</link>
            <guid isPermaLink="false">https://medium.com/p/b96d5996a632</guid>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[sessions]]></category>
            <category><![CDATA[login-system]]></category>
            <dc:creator><![CDATA[Theon]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 08:31:16 GMT</pubDate>
            <atom:updated>2025-04-19T08:31:16.227Z</atom:updated>
            <content:encoded><![CDATA[<h3>Session or JWT: Two ways to implement login</h3><p>The problem is: how to implement a login system in website?</p><p>We all know that, if a user wants to log in some application, username and password are necessary. Today, email or phone number could be substitute of username, but it’s kind of complicated for me now to implement verification of email or phone number. So let’s just talk about username and password.</p><p>Originally, we could imagine that servers keep a storage of usernames and passwords, comparing them with user’s input when log in request is received. But, as a special property of HTTP and RESTful API, which is used so widely in web development, “stateless” means servers would forget user’s login status. That’s why things become difficult, how could server tell a request comes from users or strangers?</p><p>The answer is, each request needs to carry additional information to be verified. Of course we can not use password directly, as sending password repeatedly will increase risk. Request must carry some token, which could be verified by backend. There are two ways to implement this verification.</p><p>One way is to store tokens in database. So what we should do is comparison. At first the user log in with password, then the server would generate a token and store the token in database. The token would be sent back to user as well, after which the user would carry it in every request. The server could verify the token with tokens in database. That’s it. Sounds great and safe.</p><p>The other way is to store a JWT on client side. JWT (JSON Web Token) is an encrypted user’s json-formatted information. It’s unique for every user to ensure unique verification. To encrypt user’s information, a key is required, which is stored privately on the back-end server. After user’s login, a JWT would be sent back to the user. All request would carry the JWT to be verified by the server. The safety of user’s information in JWT is ensured by encryption algorithm.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b96d5996a632" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>