examples/session: Add code that demonstrates altering session data
This commit is contained in:
parent
5d7375a9e3
commit
a1570ddbeb
@ -37,4 +37,27 @@ Here is a horse:
|
|||||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⠤⣤⣤⣤⡤⠴⠛⠛⠛⠛⠉⠁⠀⠀⠀⠀⠈⠉⢿⣄⣀⣠⣤⡤⠶⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⠤⣤⣤⣤⡤⠴⠛⠛⠛⠛⠉⠁⠀⠀⠀⠀⠈⠉⢿⣄⣀⣠⣤⡤⠶⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Twilight sparkle demands that you [memorize](.) the sacred powers of two!
|
||||||
|
|
||||||
|
{{$list := $session.Get "list" | default (list 1)}}
|
||||||
|
{{range $list}}
|
||||||
|
- {{.}}
|
||||||
|
{{end}}
|
||||||
|
{{$last := last $list}}
|
||||||
|
{{if lt $last 1}}
|
||||||
|
graaaah computer explode xP
|
||||||
|
{{else}}
|
||||||
|
{{$list = $last | mul 2 | append $list}}
|
||||||
|
{{$session.Set "list" $list}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
{{$counter := $session.Get "counter" | default 0}}
|
||||||
|
You have refreshed the page {{$counter}} times.
|
||||||
|
{{$counter = add $counter 1}}
|
||||||
|
{{$session.Set "counter" $counter}}
|
||||||
|
|
||||||
|
{{if gt $counter 100}}Why?{{end}}
|
||||||
|
|
||||||
[Exit session](logout.step).
|
[Exit session](logout.step).
|
||||||
|
Loading…
Reference in New Issue
Block a user