# WebSession use question

**URL:** <https://forum.xojo.com/t/websession-use-question/10140>\
**Category:** Web\
**Created:** [August 7, 2013, 3:42am UTC](https://forum.xojo.com/t/websession-use-question/10140 "2013-08-07T03:42:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francisco\_Lobo1](https://forum.xojo.com/user_avatar/forum.xojo.com/francisco_lobo1/32/3929_2.png) [@Francisco\_Lobo1](https://forum.xojo.com/u/Francisco_Lobo1)\
**Post date:** [August 7, 2013, 3:42am UTC](https://forum.xojo.com/t/websession-use-question/10140/1 "2013-08-07T03:42:22Z")

</div>

I am working on a router class that will hold a stack of navigated pages so you can push a page or pop from a page… The router class is responsible for showing the page. This router receives the instance of the new page and a session. Then it will set the session.currentpage property to the new page… There’s a lot of other logic going on that performs some other things, but for my question I simplified this.

The way I am doing this is having my router class being a property in the user WebSession. Then whenever I want to route a page, I also send the current session. Say I am on a button in a webpage PageA and want to route to a webpage PageB :

I will say in the buttons “ACTION” event:

```auto
Dim PageB as new WebPage
Session.router.pushpage(PageB, Session)
```

The router class in turn will grab the Session object and set the .currentpage property to the new page.

So my question is if this functionality will work? Will the session be always pointing to the right session or will I have to send a context to my router class instead of a session?

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [August 7, 2013, 11:29pm UTC](https://forum.xojo.com/t/websession-use-question/10140/2 "2013-08-07T23:29:37Z")

</div>

Make sure you are storing a WeakRef to the session, or you’ll have created a memory leak and the sessions will never get disposed of when users disconnect.

---

<div class="post-metadata">

**Author:** ![Francisco\_Lobo1](https://forum.xojo.com/user_avatar/forum.xojo.com/francisco_lobo1/32/3929_2.png) [@Francisco\_Lobo1](https://forum.xojo.com/u/Francisco_Lobo1)\
**Post date:** [August 8, 2013, 12:04am UTC](https://forum.xojo.com/t/websession-use-question/10140/3 "2013-08-08T00:04:23Z")

</div>

Thanks… However quick question. I am not storing the session anywhere, I am just using it when it get’s passed…

[code]Dim PageB as new WebPage  
Session.router.pushpage(PageB, Session)

[/code]

In the RouterClass:

```auto
Session.CurrentPage = PageB
```

Should i declare the method in the class with a WeakRef ?

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [August 8, 2013, 12:45am UTC](https://forum.xojo.com/t/websession-use-question/10140/4 "2013-08-08T00:45:44Z")

</div>

No that’s good.

---

<div class="post-metadata">

**Author:** ![Francisco\_Lobo1](https://forum.xojo.com/user_avatar/forum.xojo.com/francisco_lobo1/32/3929_2.png) [@Francisco\_Lobo1](https://forum.xojo.com/u/Francisco_Lobo1)\
**Post date:** [August 8, 2013, 1:40am UTC](https://forum.xojo.com/t/websession-use-question/10140/5 "2013-08-08T01:40:43Z")

</div>

Thank you…

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:47pm UTC](https://forum.xojo.com/t/websession-use-question/10140/6 "2020-10-29T16:47:43Z")

</div>


