Session Usage in gatling

How to use session in Gatling?

Lets say my application is returning an token in a response so how to save that token from url.

I know that we can use session but I have no idea how to do that.

Please help in writing the .scala file for above scenario?

You can do it like this:

http(“doLogin”)

.post("/sign_in")
.formParam(""“user[login]”"", “”“gatling”"")

.formParam(""“user[password]”"", “”“123456"”")

.formParam("""…""","""…""")
.

.check(regex("""<meta content="(.*?)" name=“csrf-token”"").saveAs(“token”))

Thanks Gregory ,

I am trying to do so. But I am getting some error. Can you verify me again with correct syntax to extract a parameter from response url. Now I need to fetch two parameters and how to print them in my simulation script.

Please help me?