Skip to content

Commit a8558ef

Browse files
authored
Merging to release-5.9: Add a Note on the availability of ctx.GetSession(r) in the middleware chain (#6959)
Add a Note on the availability of `ctx.GetSession(r)` in the middleware chain (#6959)
1 parent a61660d commit a8558ef

File tree

1 file changed

+7
-0
lines changed
  • tyk-docs/content/api-management/plugins

1 file changed

+7
-0
lines changed

tyk-docs/content/api-management/plugins/golang.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,13 @@ func MyPluginFunction(w http.ResponseWriter, r *http.Request) {
518518
}
519519
```
520520

521+
{{< note warning >}}
522+
**Note**
523+
524+
Tyk Gateway sets the session in the [Authentication layer]({{< ref "api-management/traffic-transformation#request-middleware-chain" >}}) of the middleware chain. Because of this, the session object does not exist until the middleware chain runs after the authentication middleware. If you call `ctx.GetSession` inside a custom auth plugin, it will always return an empty object.
525+
526+
{{< /note >}}
527+
521528
The invocation of `ctx.GetSession(r)` returns an SessionState object.
522529
The Go data structure can be found [here](https://github.com/TykTechnologies/tyk/blob/master/user/session.go#L106).
523530

0 commit comments

Comments
 (0)