# MAJOR weak\_map GetSession() broken in 26.10

**URL:** <https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369>\
**Category:** Issues and Bug Reporting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, fortnite\
**Created:** [September 12, 2023, 2:33pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369 "2023-09-12T14:33:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [September 12, 2023, 2:33pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/1 "2023-09-12T14:33:30Z")

</div>

### Please select what you are reporting on:

Unreal Editor for Fortnite

### What Type of Bug are you experiencing?

Verse

### Summary

weak\_map GetSession() broken in 26.10. when I use the weak\_map setup to save an int in between rounds it no longer works, it does not save. See video

### Steps to Reproduce

See video for code or see here, the button I press ends the round:  
verse file 1:

```auto
using { /Verse.org/Simulation }

var GlobalInt:weak_map(session,int) = map{}
Func():void={
    if(A := GlobalInt[GetSession()]):
        if(set GlobalInt[GetSession()] = 2){} 
    else:
        if(set GlobalInt[GetSession()] = 1){} 

    
    if(A := GlobalInt[GetSession()]):
        Print("A {A}")
}

```

verse file 2:

```auto
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

testdevice := class(creative_device):
    OnBegin<override>()<suspends>:void=
        Func()

```

### Expected Result

It save between rounds, in round 2 the value should be 2 (or print “A 2”)

### Observed Result

### Platform(s)

PC

---

<div class="post-metadata">

**Author:** ![Bug-Reporter](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bug-reporter/32/1223650_2.png) [@Bug-Reporter](https://forums.unrealengine.com/u/Bug-Reporter)\
**Post date:** [September 13, 2023, 1:18am UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/2 "2023-09-13T01:18:58Z")

</div>

The status of UCB-909 incident has been moved from ‘Done’ to ‘Closed’.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Strelka](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Giovanni\_Strelka](https://forums.unrealengine.com/u/Giovanni_Strelka)\
**Post date:** [September 13, 2023, 6:54pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/3 "2023-09-13T18:54:54Z")

</div>

We’ve verified the same in our islands. Can confirm it is broken since yesterday.

---

<div class="post-metadata">

**Author:** ![spankysully1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spankysully1/32/1076932_2.png) [@spankysully1](https://forums.unrealengine.com/u/spankysully1)\
**Post date:** [September 13, 2023, 8:14pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/4 "2023-09-13T20:14:00Z")

</div>

Can confirm the issue as well.

---

<div class="post-metadata">

**Author:** ![DolphinDom](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dolphindom/32/637016_2.png) [@DolphinDom](https://forums.unrealengine.com/u/DolphinDom)\
**Post date:** [September 13, 2023, 9:03pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/5 "2023-09-13T21:03:43Z")

</div>

Broken on my end too.

---

<div class="post-metadata">

**Author:** ![toom1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@toom1](https://forums.unrealengine.com/u/toom1)\
**Post date:** [September 14, 2023, 2:03am UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/6 "2023-09-14T02:03:14Z")

</div>

Really annoying bug, but they did change something in the digest about weak maps so I wonder if its intentional?

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [September 14, 2023, 6:13am UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/7 "2023-09-14T06:13:54Z")

</div>

For your information.

v26.00

```auto
    # 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

```auto
    # 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

```

---

<div class="post-metadata">

**Author:** ![Nman\_Pkr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nman_pkr/32/1194697_2.png) [@Nman\_Pkr](https://forums.unrealengine.com/u/Nman_Pkr)\
**Post date:** [September 15, 2023, 2:45am UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/8 "2023-09-15T02:45:11Z")

</div>

Looks either intentional or someone accidentally reverted to an older version of the file before packaging the release.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Strelka](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Giovanni\_Strelka](https://forums.unrealengine.com/u/Giovanni_Strelka)\
**Post date:** [September 26, 2023, 12:27pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/9 "2023-09-26T12:27:09Z")

</div>

These Notes are still there in the Verse digest for version 26.20, hinting that nothing got touched in that area.

---

<div class="post-metadata">

**Author:** ![UltimateLambda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ultimatelambda/32/916183_2.png) [@UltimateLambda](https://forums.unrealengine.com/u/UltimateLambda)\
**Post date:** [September 27, 2023, 5:02pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/10 "2023-09-27T17:02:32Z")

</div>

This is unfortunately intended. Use of `session` as a key in a module-scoped `var` `weak_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.

```auto
if:
  set GlobalInt[GetSession()] = 0

```

---

<div class="post-metadata">

**Author:** ![LoPing](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/loping/32/737300_2.png) [@LoPing](https://forums.unrealengine.com/u/LoPing)\
**Post date:** [September 28, 2023, 9:26am UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/11 "2023-09-28T09:26:23Z")

</div>

(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.

---

<div class="post-metadata">

**Author:** ![UltimateLambda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ultimatelambda/32/916183_2.png) [@UltimateLambda](https://forums.unrealengine.com/u/UltimateLambda)\
**Post date:** [September 29, 2023, 6:05pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/12 "2023-09-29T18:05:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![LoPing](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/loping/32/737300_2.png) [@LoPing](https://forums.unrealengine.com/u/LoPing)\
**Post date:** [September 29, 2023, 10:29pm UTC](https://forums.unrealengine.com/t/major-weak-map-getsession-broken-in-26-10/1292369/13 "2023-09-29T22:29:21Z")

</div>

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](https://forums.unrealengine.com/t/global-session-variables-not-working/1314794)  
Private island with works-in-editor session variables: #8168-1632-6083
