Session Events - Session Props

I’m trying to set custom props in the Session Events on Startup. Basically i’m trying to access session.props.auth.user properties. But I keep getting back NoneType errors.

Oddly if I log this in the session event:

logger = system.util.logger(“myLogger”)
logger.info(session.props.id)
logger.info(str(session.props.auth.authenticated))

myLogger has shows the session id but the authenticated value is False. But on one of my views there is a label’s text property I’ve linked to the authenticated value and it shows true.

So, are not all session properties set when you are in Session Events? Are they set after start up?

Session properties change throughout the lifecycle of the session, which is why they’e not called session parameters. A session (essentially) starts the moment a project is reached in a web browser (before any login takes place; you can see this yourself by examining your Gateway and looking in Status > Perspective Sessions. Now launch a project which requires authentication and you’ll see that there’s an active session, even though the user has not logged in.

oh okay, thanks! That helps.

The reason for using the startup session was I wanted to get the role(s), firstName, lastName. They’re used to grab extra info from our database to populate custom props. I wanted to grab that info before anything is seen to the user. The custom props are then used throughout the app.

What do you think is the best approach for that? Basically I don’t want a user to see information that they shouldn’t see.

There are numerous ways to prevent a user from seeing Views, content, or components they shouldn’t see.

Security Levels:
Add users to Security Levels to prevent them from seeing Views (more of a “users should never see the content in this View unless they have the required Security Level” approach).

Component-level visibility:
You can make components invisible or disabled based on bindings against properties.

Could you provide an example of how something might be displayed you wouldn’t want a certain user to see and how you would determine if they should see it or not?

Thank you! Security levels crossed my mind as well. Wasn’t sure if it would work and was trying to make some things generic.

One example is we have people associated with a specific “Territory” with specific information for that territory in a database. We grab the “Territory” by seeing the user from the session and then query our database to see what the “Territory” is for that user. Then there’s database queries made for that “Territory” that fill in things like line charts, bar chart, tables etc.

That’s why i was thinking the startup session would be best before any views are actually seen. But maybe it’s okay to grab that “Territory” information from the “StartUp” event on the initial view seen? I’m not quite sure where else to initiate that.

Thanks again!

Yes, instances like you described are a good example of when to use View StartUp Events.

In this and other posts made by you, you refer to “View StartUp Events”. Where do I find these as they are not listed under that name in the user manual.

View startup is shorthand for the onStartup event that can be configured on views (and all other Perspective components, for that matter). There’s a bug where you sometimes don’t see the ‘Configure Events’ menu item when right clicking views - try the keyboard shortcut (Ctrl → J) or just click into the editing pane and then right click the view.

@weertske: They can be found here in the documentation.

As @PGriffith explained, they can be found by selecting a View node in the Project Browser, then right-clicking that same View node and selecting “Configure Events”.

Try to use terminology that matches your manual. So when users search for a term that you use repeatedly it shows up clearly.