# Not seeing session startup happen?

**URL:** <https://forum.inductiveautomation.com/t/not-seeing-session-startup-happen/54109>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [December 14, 2021, 6:28pm UTC](https://forum.inductiveautomation.com/t/not-seeing-session-startup-happen/54109 "2021-12-14T18:28:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 14, 2021, 6:28pm UTC](https://forum.inductiveautomation.com/t/not-seeing-session-startup-happen/54109/1 "2021-12-14T18:28:16Z")

</div>

Working on a new perspective project. When a client starts up a new session of the application, I want to write two datetimes to custom session properties that will be used in date filter across the project.

Right now under my session Startup Script I have

```auto
def onStartup(session):
	"""
	Called when a new session is authorized and starts.

	Arguments:
		session: A reference to the newly created session
	"""
	import client.eventscripts
	import system.perspective
	system.perspective.print("About to do session startup")
	client.eventscripts.sessionStartUp(session)

```

and in my `client.eventscripts`

```auto
import system.perspective
import system.date

def sessionStartUp(session):
	system.perspective.print("Session starting!")
	now = system.date.now()
	session.custom.Filter_Plant = 0
	session.custom.Filter_StartDT = system.date.addHours(now, -8)
	session.custom.Filter_EndtDT = system.date.addHours(now, 24)
	system.perspective.print("Set times")

```

However, when I start a new session, the filters that are bound to `session.custom.Filter_StartDT` are what they were left as in designer, and I don’t see any of the print messages in my console -  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/e/fe551329873c6fd0254b3f1095d6b2620dc22fc1.png)

I’ve made sure my project is saved, I’ve launched a new session from the designer, from the gateway, and directly through the URL in a incognito window, but no matter how none of my print statements show (I thought perhaps I was not creating a new session). Any thoughts on what I could be doing wrong? Using Ignition 8.1.10 here.

Currently we are testing on a corporate network so anyone who is on network can access it - no logging in required if that matters at all.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 14, 2021, 6:32pm UTC](https://forum.inductiveautomation.com/t/not-seeing-session-startup-happen/54109/2 "2021-12-14T18:32:40Z")

</div>

Any errors in the gateway logs? It’s _possible_ that `system.perspective.print` doesn’t work right in startup scripts, since the backing session isn’t fully constructed yet; I would be somewhat surprised but could see that as a possibility.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 14, 2021, 6:47pm UTC](https://forum.inductiveautomation.com/t/not-seeing-session-startup-happen/54109/3 "2021-12-14T18:47:56Z")

</div>

Ah I finally did get something come through (had an issue on onPageStartup that I think was taking precedence)-

```auto
com.inductiveautomation.ignition.common.script.JythonExecException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective page attached to this thread.

at org.python.core.Py.JavaError(Py.java:547)

at org.python.core.Py.JavaError(Py.java:538)

at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:192)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:546)

at org.python.core.PyObject. __call__ (PyObject.java:461)

at org.python.core.PyObject. __call__ (PyObject.java:465)

at org.python.pycode._pyx16.onStartup$1(:5)

at org.python.pycode._pyx16.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:173)

at org.python.core.PyBaseCode.call(PyBaseCode.java:306)

at org.python.core.PyFunction.function ___call__ (PyFunction.java:474)

at org.python.core.PyFunction. __call__ (PyFunction.java:469)

at org.python.core.PyFunction. __call__ (PyFunction.java:464)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:849)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:831)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:689)

at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:1000)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:754)

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:133)

at com.inductiveautomation.perspective.gateway.script.ScriptRunner.run(ScriptRunner.java:23)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective page attached to this thread.

... 25 common frames omitted

Caused by: java.lang.IllegalArgumentException: No perspective page attached to this thread.

at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.lambda$operateOnPage$0(AbstractScriptingFunctions.java:64)

at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:120)

at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47)

at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.print(PerspectiveScriptingFunctions.java:511)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:190)

... 22 common frames omitted

```

So seems like perhaps you need a page to do a `system.perspective.print`? Either way, I’ve removed the system.perspective.print’s as the real goal is to just set the datetimes and that still seems problematic.

The session custom properties were persistent which I removed though I don’t think that should have been necessary.

Currently the new session startup script is

```auto
import client.eventscripts
client.eventscripts.sessionStartUp(session)

```

and `client.eventscripts`

```auto
import system.perspective
import system.date

def sessionStartUp(session):
	now = system.date.now()
	# Doesn't exist
#	session.custom.Filter_Plant = 0
	session.custom.Filter_StartDT = system.date.addHours(now, -8)
	session.custom.Filter_EndtDT = system.date.addHours(now, 24)

```

and an example of one of the two bindings -  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/a/ba3c60f60ce9d20a2b761ff15bac2e8b7474b957.png)

Right now when I load a new session the two datetimes picking components now come up with a red overlay and blank  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/385bee841b7b2ad47d06c674b7ed54a80fa17d03.png)

Since my changes that caused the red overlay, I do not see any thing pop up in the logs or in the browser console. I don’t know where to go from here.

If there’s perhaps a better way to initialize these times as well, I am open to a different answer to this problem.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 14, 2021, 6:51pm UTC](https://forum.inductiveautomation.com/t/not-seeing-session-startup-happen/54109/4 "2021-12-14T18:51:35Z")

</div>

Can they just be custom properties with expression bindings? `now(0)` shouldn’t poll, so they should only evaluate once on session startup.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 14, 2021, 6:54pm UTC](https://forum.inductiveautomation.com/t/not-seeing-session-startup-happen/54109/5 "2021-12-14T18:54:07Z")

</div>

I either forgot or was unaware `now(0)` does not poll but that that seems cleaner. It’s working! Thanks. Been a while since I’ve touched perspective.
