NetTalk Central

Author Topic: Session Login value being set to 0  (Read 4429 times)

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Session Login value being set to 0
« on: September 28, 2014, 07:47:33 AM »
Hi

My tables all have variable file names in the dictionary like !FIL:Services.  I set these names in the Web Handler - Process link embed after the Login code sets up the components of the file name (like 'username' which is a sub-directory.

I added a field lookup on the Services table and something very weird happened.  The Services browse 'pops' up ok but when a row was selected the application returned Error 45 - Invalid file name.

The process I use to construct the file names is:  the file path is stored in a system file 'Control', 'username' is set on login and the rest of the name is a constant.  The actual code is:

  if p_web.GetSessionLoggedIn() > 0  !user is logged in
     FIL:Services = CLIP(CON:filePath) & p_web.GSV('username') & '\Services.tps'
     <other files>
  end

This has all worked fine but then I added functionality to allow some users to be explicitly logged on (and they are allowed only a limited set of Menu options).  This is achieved thru a URL value:

http://127.0.0.1:8094/?b=bill

The 'b' is a subdirectory name and I use it in lieu of a Login to construct the file name. I have the following code in the Web Handler - Process Link embed:

  p_web.StoreValue('b')
  if p_web.GSV('b') not= ''  !this is an inquiry
    relate:clients.OPEN()   
    Cli:Name = p_web.GSV('b')
    Access:Clients.Fetch(Cli:byName)
    p_web.SSV('username',Cli:Name)
    p_web.SSV('business',Cli:FullName)
    p_web.SetSessionLoggedIn(1)
    p_web.SetSessionLevel(1)
    STOP(p_web.GetSessionLoggedIn())
    Relate:Clients.close()
  END 

So, the idea was to explicitly do the login and set the 'username' so that the file name could be constructed.

This code worked fine but I then added a field lookup and the lookup file browse 'pops' up ok but returns a file access error when a row is selected.

The above code is executed following the 'select a row' and the STOP shows that the logged in value is 0 even though it is set to 1 two lines before. This means that later in the code the filename variable - FIL:Services is not set properly and returns a value of blank.

I displayed the value of FIL:Services and it was blank but other similar file name variables were not which is most odd.

Any ideas on what this could be and why the SessionLoggedIn value is being set to 0?

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Session Login value being set to 0
« Reply #1 on: September 28, 2014, 02:12:00 PM »
PS

When I remove the Lookup (un-tick the Lookup attribute) the problem goes away.

Also, the lookup procedure is used elsewhere ok.

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Session Login value being set to 0
« Reply #2 on: September 28, 2014, 10:25:57 PM »
is  FIL:Services marked as THREADed ?

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Session Login value being set to 0
« Reply #3 on: September 29, 2014, 01:12:36 AM »
Bruce

Yes FIL:services and the other Name fields are threaded.

There are two bits of WebHandler - ProcessLink code - CodeA is followed immediately by CodeB.

CodeA
  p_web.StoreValue('b')
  if p_web.GSV('b') not= ''  !this is an inquiry
    relate:clients.OPEN()   
    Cli:Name = p_web.GSV('b')
    Access:Clients.Fetch(Cli:byName)
    P_web.SSV('username',Cli:Name)
    p_web.SSV('business',Cli:FullName)
    p_web.SetSessionLoggedIn(1)
    p_web.SetSessionLevel(1)
    Relate:Clients.close()
  END 

As noted, I imagined that this code would only be executed if the beginning URL ended in ?b=<something>.  I also thought that if this code got executed again during the session that the Value of 'b' would remain even though the URL was changing.  The code sets up the 'username' Session Variable which is used to construct the filenames.

CodeB
  if p_web.GetSessionLoggedIn() > 0  !user is logged in
     Relate:Control.OPEN()
     SET(control)
     Access:Control.NEXT()   
     FIL:Customers         = CLIP(CON:filePath) & p_web.GSV('username') & '\Customers.tps'
     FIL:Bookings          = CLIP(CON:filePath) & p_web.GSV('username') & '\Bookings.tps'
     FIL:Rooms             = CLIP(CON:filePath) & p_web.GSV('username') & '\Rooms.tps'
     FIL:Pets              = CLIP(CON:filePath) & p_web.GSV('username') & '\Pets.tps'
     FIL:Services          = CLIP(CON:filePath) & p_web.GSV('username') & '\Services.tps'
     FIL:RoomsBooked       = CLIP(CON:filePath) & p_web.GSV('username') & '\RoomsBooked.tps'
     FIL:BookedServices    = CLIP(CON:filePath) & p_web.GSV('username') & '\BookedServices.tps'
     FIL:BookedPets        = CLIP(CON:filePath) & p_web.GSV('username') & '\BookedPets.tps'
     FIL:Quotes            = CLIP(CON:filePath) & p_web.GSV('username') & '\Quotes.tps'
  END   

SessionLoggedIn is set to 1 either in CodeA or in the Login code.  Here we are only considering the CodeA case.  Note that in the scenario below when CodeB is not executed it indicates that Logged In is 0.

This is what happens:

Execute with URL=http://127.0.0.1:8094?b=bill
WebHandler: CodeA executed - 'username' correctly set, session is logged in.
WebHandler: CodeB executed - Services fully qualified file name correctly set
The correct menu item 'Get a Quote' is displayed.

Click on 'Get a Quote' Menu item
URL still has ?b=bill
WebHandler: CodeA executed - 'username' correctly set, session is logged in.
WebHandler: CodeB executed - Services fully qualified file name correctly set
WebHandler: CodeA executed - 'username' correctly set, session is logged in.
WebHandler: CodeB executed - Services fully qualified file name correctly set
(Yes, this happens twice, (I wouldn't mind understanding why))
URL now changes to http://127.0.0.1:8094/uQuotes
The Quotes Form is correctly displayed

On the Quotes form the Lookup icon on the Service field is clicked
A blank 'Services' Browse is displayed
WebHandler: CodeA executed - 'username' correctly set, session is logged in.
WebHandler: CodeB executed - Services fully qualified file name correctly set
WebHandler: CodeA is not executed
WebHandler: CodeB is not executed
At the end of CodeB the Services file name is blank
The file error (45) is posted

In my first post I said that the file error occurs after a selection is made on the Services browse.  Today I have had one case where that happened but all other cases (about 10) are as described above.

Thanks again for taking the time to look into this


Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Session Login value being set to 0
« Reply #4 on: September 29, 2014, 01:31:56 AM »
PPS

I just ran another test of the code and got different behaviour again.  This time, before getting the file error I got multiple executions of the Web Handler Process Link code (5-10) after firing off the first URl and then after selecting the menu item etc.  The behaviour is not consistent.

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Session Login value being set to 0 - I have a lead
« Reply #5 on: September 29, 2014, 07:16:27 PM »
Hi, I am working on an angle and may solve today.  I will let you know if I have success.

Cheers

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27