NetTalk Central

Author Topic: Determine if user is logged in when customizing 404 error  (Read 2975 times)

vsorensen

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • Email
Determine if user is logged in when customizing 404 error
« on: September 03, 2008, 11:23:42 AM »
When a session has timed out, and a user clicks on a link, they get a "404 page not found" error.  My client has requested that if the user is not logged in, they get a "Session ended due to inactivity" page instead. 

ThisWebServer.MakeErrorPage() is the place to customize the 404 response, but there's no SessionID available at that point, so I can't call _GetSessionLoggedIn in order to tell what to show.

Is there a way of doing this?

David

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Re: Determine if user is logged in when customizing 404 error
« Reply #1 on: September 03, 2008, 05:54:50 PM »
I think you are getting the 404 error because you have not told NetTalk what page to go to if the use has to be logged in.

On your WebServer procedure:
1. Double Click the WebServer Extention, Click Setting, General Tab
2. Fill in the Logon Page prompt with the name of your login page ex. 'logon.html'

Then when the session times out and a user clicks on a link that requires them to be logged in, they will be re-directed to your logon page.  Attached is a screen print.

[attachment deleted by admin]

Poul

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Determine if user is logged in when customizing 404 error
« Reply #2 on: September 04, 2008, 06:07:02 AM »
When you are at the "404 page not found" point if you have a sessionid
its a 404, if you don't - can't you make an assumption?

but you could also use a variable for the login form, so
after you get in the first time, could you change it from a loginform to your own inactivityform? -- preserved via a session variable.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Determine if user is logged in when customizing 404 error
« Reply #3 on: September 04, 2008, 06:54:29 AM »
Hi Vince,

I think the worker class needs a MakeErrorPage method, that usually just calls the Server class. Then you can override this method in the WebHandler (and there you will have the session ID).
I'll try and squeeze this into the next build (which is coming out tomorrow).

Cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Determine if user is logged in when customizing 404 error
« Reply #4 on: September 04, 2008, 06:56:49 AM »
Hang on, there's already a NetWebServerWorker.MakeErrorPacket method.
Although it's probably a fairly recent addition.

So in WebHandler you can override that (look at the code in netweb.clw for the sort of things you should put in there.

Cheers
Bruce

vsorensen

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • Email
Re: Determine if user is logged in when customizing 404 error
« Reply #5 on: September 08, 2008, 09:49:46 AM »
I had changed the name of the login page without updating the template settings, so that solved the problem to the satisfaction of the end client, but I'm still going to play around with making a custom error based on the login status.

Thanks all!