# Type for which there is a single value per server instance. Use `GetSession` to get the current server instance `session`. May be used with `weak_map` to mimic global variables in other languages.
session<native><public> := class<unique><module_scoped_var_weak_map_key><epic_internal>:
# Returns the `session` corresponding to the current server instance. The result can be used with `weak_map` to mimic global variables in other languages.
GetSession<native><public>()<varies>:session
v26.10
# Type for which there is a single instance per round. Use `GetSession` to get the current round's `session` instance. May be used with `weak_map` to implement global variables.
# Note: may be changed in a future release to a single instance per game. Round-local behavior should not be relied upon.
session<native><public> := class<unique><module_scoped_var_weak_map_key><epic_internal>:
# Returns the `session` corresponding to the current round. The result can be used with `weak_map` to implement global variables.
# Note: may be changed in a future release to return a single instance per game. Round-local behavior should not be relied upon.
GetSession<native><public>()<varies>:session
This is unfortunately intended. Use of session as a key in a module-scoped varweak_map may eventually gain back support for cross-round state (hence the scary āNote: ā¦ā part of the doc), but it was removed in 26.10. To protect against a behavior change (when cross-round state is added back), make sure to initialize your state at the beginning of OnBegin in a creative_device, e.g.
(1) Any feel if they will be adding it back in the next upgrade? The change broke a lot of islands. Thanks!
(2) Is there any work around to keep an int or float between rounds?
PSā very weird, but I have an island where my two session variables work perfectly when running a session from the editor, but like everyone elseās, they fail when published.
Unfortunately, I canāt give any information about when it will be added back, even for int or float. Can you can more details about session variables working in the editor, but not when published?
I could supply the island, but the bizarre thing is that I made a fresh āhello worldā map using a weak mapped session-to-int variable, and it didnāt even work in the editor. I literally copied and pasted Epicās example from the documentation.
I broke the process down into three steps and (a) writing to a weakly mapped session variable has no problem, (b) reading from that same variable in the same session, no problem (c) ending and restarting the game completely erases the previously stored variable.
On the other hand, my map created before the last two upgrades saves the round number(int) and shortest completion time (float) absolutely perfectly between rounds when run from the editor. You can play ten games in the same session, and it works every single time. Not in Fortnite.
This makes me think that projects created before the last two updates have the works-in-the-editor-not-in-the-game property, while projects created afterword never retain the global, session value in either in UEFN or in Fortnite. Itās like there is a storage spot for global variables in Islands created before the last two patches that no longer exists for newly created maps.
I posted this all in a bug report, my āhello worldā map referred to in the report is the simplest possible map that displays the property, so it may save some time if someone is working on the issue. I can supply my old map if you want to look at something that works in the editor, itās fairly involved though.
Bug Report
Private island with works-in-editor session variables: #8168-1632-6083