Get will get/create a session. This function will return an ErrSessionAlreadyLoadedByMiddleware if the session is already loaded by the middleware. Parameters: - c: The Fiber context. Returns: - *Session: The session object. - error: An error if the session retrieval fails or if the session is al
(c fiber.Ctx)
| 97 | // // handle error |
| 98 | // } |
| 99 | func (s *Store) Get(c fiber.Ctx) (*Session, error) { |
| 100 | // If session is already loaded in the context, |
| 101 | // it should not be loaded again |
| 102 | _, ok := c.Locals(middlewareContextKey).(*Middleware) |
| 103 | if ok { |
| 104 | return nil, ErrSessionAlreadyLoadedByMiddleware |
| 105 | } |
| 106 | |
| 107 | return s.getSession(c) |
| 108 | } |
| 109 | |
| 110 | // getSession retrieves a session based on the context. |
| 111 | // |