From 7a2c3b917ec7aef6bd549fe23a0a1e6f0b8f5dc8 Mon Sep 17 00:00:00 2001 From: Jimmy99 Date: Wed, 6 Apr 2016 10:58:18 +0200 Subject: [PATCH] Update 06.2.md typographical errors and improved readability --- en/06.2.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/en/06.2.md b/en/06.2.md index d5b9f282..825f9a58 100644 --- a/en/06.2.md +++ b/en/06.2.md @@ -4,7 +4,7 @@ In section 6.1, we learned that sessions are one solution for verifying users, a ## Creating sessions -The basic principle behind sessions is that a server maintains information for every single client, and clients rely on unique session ids to access this information. When users visit the web application, the server will create a new session with the following three steps, as needed: +The basic principle behind sessions is that a server maintains information for every single client, and clients rely on unique session id's to access this information. When users visit the web application, the server will create a new session with the following three steps, as needed: - Create a unique session id - Open up a data storage space: normally we save sessions in memory, but you will lose all session data if the system is accidentally interrupted. This can be a very serious issue if web application deals with sensitive data, like in electronic commerce for instance. In order to solve this problem, you can instead save your session data in a database or file system. This makes data persistence more reliable and easy to share with other applications, although the tradeoff is that more server-side IO is needed to read and write these sessions. @@ -67,7 +67,7 @@ We know that we can save sessions in many ways including in memory, the file sys SessionGC(maxLifeTime int64) } -- `SessionInit` implements the initialization of a session, and returns new a session if it succeeds. +- `SessionInit` implements the initialization of a session, and returns a new session if it succeeds. - `SessionRead` returns a session represented by the corresponding sid. Creates a new session and returns it if it does not already exist. - `SessionDestroy` given an sid, deletes the corresponding session. - `SessionGC` deletes expired session variables according to `maxLifeTime`. @@ -90,17 +90,17 @@ This design takes its roots from the `database/sql/driver`, which defines the in // it panics. func Register(name string, provider Provider) { if provider == nil { - panic("session: Register provide is nil") + panic("session: Register provider is nil") } if _, dup := provides[name]; dup { - panic("session: Register called twice for provide " + name) + panic("session: Register called twice for provider " + name) } provides[name] = provider } -### Unique session ids +### Unique session id's -Session ids are for identifying users of web applications, so they must be unique. The following code shows how to achieve this goal: +Session id's are for identifying users of web applications, so they must be unique. The following code shows how to achieve this goal: func (manager *Manager) sessionId() string { b := make([]byte, 32) @@ -112,7 +112,7 @@ Session ids are for identifying users of web applications, so they must be uniqu ### Creating a session -We need to allocate or get an existing session in order to validate user operations. The `SessionStart` function is for checking if any there are any sessions related to the current user, creating a new session non are found. +We need to allocate or get an existing session in order to validate user operations. The `SessionStart` function is for checking the existence of any sessions related to the current user, and creating a new session if none is found. func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (session Session) { manager.lock.Lock() @@ -177,7 +177,7 @@ Because sessions have the concept of an expiry time, we define the GC to update ### Reset sessions -We know that web application have a logout operation. When users logout, we need to delete the corresponding session. We've already used the reset operation in above example -now let's take a look at the function body. +We know that web applications have a logout operation. When users logout, we need to delete the corresponding session. We've already used the reset operation in above example -now let's take a look at the function body. //Destroy sessionid func (manager *Manager) SessionDestroy(w http.ResponseWriter, r *http.Request){