# Genie.jl, global session variables

**URL:** <https://discourse.julialang.org/t/genie-jl-global-session-variables/33260>\
**Category:** New to Julia\
**Tags:** web, website, genie\
**Created:** [January 12, 2020, 5:23am UTC](https://discourse.julialang.org/t/genie-jl-global-session-variables/33260 "2020-01-12T05:23:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BMval](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bmval/32/7647_2.png) [@BMval](https://discourse.julialang.org/u/BMval)\
**Post date:** [January 12, 2020, 5:23am UTC](https://discourse.julialang.org/t/genie-jl-global-session-variables/33260/1 "2020-01-12T05:23:29Z")

</div>

I need to write a very easy web application, in which I need to use Julia’s function. So I try to use Genie. To be honest, I don’t find good documentation, even the official doc isn’t full.

I wrote the simplest example. I need to understand how to work session variables.

> using Genie, Genie.Router, Genie.Requests, Genie.Renderer.Html  
> function main()  
> i=1  
> route(“/test”) do  
> i = i+1  
> “test $i”  
> end  
> up()  
> end  
> main()

Would you suggest, how to create global variables for the session? Right now I have global variable for the whole site.

Thank you

P.S. Maybe you can suggest other libraries. Everything that I need, just to work with Get and Post request.

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [January 12, 2020, 4:49pm UTC](https://discourse.julialang.org/t/genie-jl-global-session-variables/33260/2 "2020-01-12T16:49:02Z")

</div>

If you want to try other libraries, then maybe something of this would be useful:

- [JuliaWebAPI](https://github.com/JuliaWeb/JuliaWebAPI.jl)
- [Pages](https://github.com/EricForgy/Pages.jl)
- [Joseki](https://github.com/amellnik/Joseki.jl)
- [Bukdu](https://github.com/wookay/Bukdu.jl)

Also you can take a look at [DiffEqOnlineServer](https://github.com/JuliaDiffEq/DiffEqOnlineServer).

---

<div class="post-metadata">

**Author:** ![yoh-meyers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yoh-meyers/32/14700_2.png) [@yoh-meyers](https://discourse.julialang.org/u/yoh-meyers)\
**Post date:** [May 8, 2020, 5:12pm UTC](https://discourse.julialang.org/t/genie-jl-global-session-variables/33260/3 "2020-05-08T17:12:23Z")

</div>

I would add to list my new lightweight web framework: [dance.jl](https://github.com/DanceJL/Dance.jl).

As per docs:

```julia
using Dance.Router

i = 0

function test() :: String
   global i
   i = i+1
   return ""
end

route("/", test; endpoint=HTML, method=GET)

```

Once you end session, i will be 0 again

---

<div class="post-metadata">

**Author:** ![Tillmann\_Bosch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tillmann_bosch/32/52480_2.png) [@Tillmann\_Bosch](https://discourse.julialang.org/u/Tillmann_Bosch)\
**Post date:** [November 3, 2023, 1:33pm UTC](https://discourse.julialang.org/t/genie-jl-global-session-variables/33260/4 "2023-11-03T13:33:19Z")

</div>

Hey, I hope you could already solve your problem. I dont have a good answer to your global variables, but a simple server setup which works fine for get and post could be:

```julia
import Genie: up
import Genie.Router: route, POST
import Genie.Requests: jsonpayload

function do_something()
	jsonpayload()
end

function run_server()
	route("/", () -> (:message => "Hey there!"))
	route("/myroute", do_something, method=POST)
	up(8000, async = false)
end

```
