# NameError: global name 'session' is not defined

**URL:** <https://forum.inductiveautomation.com/t/nameerror-global-name-session-is-not-defined/40970>\
**Category:** Ignition\
**Tags:** ignition80, scripting\
**Created:** [November 25, 2020, 9:15pm UTC](https://forum.inductiveautomation.com/t/nameerror-global-name-session-is-not-defined/40970 "2020-11-25T21:15:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 25, 2020, 9:15pm UTC](https://forum.inductiveautomation.com/t/nameerror-global-name-session-is-not-defined/40970/1 "2020-11-25T21:15:44Z")

</div>

Here’s what’s throwing that error, session.props.auth.user.userName

I have a button on a view that calls a project script that has this in it. Not sure how to get the logged in user, someone from the forums said I should use this.Thx, jake

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [November 25, 2020, 9:24pm UTC](https://forum.inductiveautomation.com/t/nameerror-global-name-session-is-not-defined/40970/2 "2020-11-25T21:24:20Z")

</div>

You’ll have to pass the buttons **self**. Sessions aren’t accesible via project scripts. But if you passed in the self of the button on the view you can access by

```auto
self.session.props.auth.user.userName
```

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 25, 2020, 9:25pm UTC](https://forum.inductiveautomation.com/t/nameerror-global-name-session-is-not-defined/40970/3 "2020-11-25T21:25:24Z")

</div>

perfect, thx.
