NetTalk Central

Author Topic: Session Values from other user?  (Read 4421 times)

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Session Values from other user?
« on: February 10, 2009, 02:39:57 AM »
Hi

I just thought I got the hang of this, but something weird happened just now.

I use a lot of memory forms and when I test myself, everytime I go to the form to add a new record all the values are perfectly cleared...

However, I got somebody else to check earlier today and as I logged in later and went to the form the previous users' input information was all right there???  I used a different computer, same result.

So what I do is:

1) Make all the local memory variables static so that it is 'remembered' in case I need to alert the user of wrong input
2) Like a good soldier, I use Validate All to check all the input fields and send the relevant alerts before writing to the disk
3) In the Post Update, I set all these memory variables to '', eg l:policyno = 0, l:contactperson = '', etc.

So what the heck am I doing wrong here, or is there an easy way of issuing one command that clear all session variables as soon as a user log in?  I was under the impression that each new session has a new set of empty session values.

Please Help

C



kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Session Values from other user?
« Reply #1 on: February 10, 2009, 03:15:04 PM »
I think you need to set your local variable as Threaded. To test them in the Validate all grab them from the session Q - no need to make them Static.

Kev

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: Session Values from other user?
« Reply #2 on: February 10, 2009, 10:22:47 PM »
Hi Charl,

You can't use static variables for the same reason you can't use global variables.
Because static & globals are common to "all users".

Remember in the web app all the users are simultaneously using the same exe.

You should use session variables to store, and retrieve variables that belong to a specific user. That's what session variables are for.

Threading the variables won't help because they'd effectively be wiped out several times with each request, so would become useless.

Cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Session Values from other user?
« Reply #3 on: February 11, 2009, 05:53:12 AM »
Bruce,

So that means I still put the variables on the local data field for use but _NOT_ static, and then I use p_web.storevalue('l:policyno',0) ,etc to "wipe" them out in my Post Update routine?

I'll try this, but what happened earlier when I was trying to do this whenever I had to alert a message the one's that has been filled out turned blank when I return to the screen...  Would do RestoreMem solve this and where to put it?

Maybe a simple example of filling a client record from a memory form where if it goes through the validate all routine would help if that's not to much to ask.

Thanks
C

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Session Values from other user?
« Reply #4 on: February 11, 2009, 01:33:53 PM »
So that means I still put the variables on the local data field for use but _NOT_ static

> correct

, and then I use p_web.storevalue('l:policyno',0) ,etc to "wipe" them out in my Post Update routine?

> use SSV - no need to wipe them out as only relate to the user logged in

I'll try this, but what happened earlier when I was trying to do this whenever I had to alert a message the one's that has been filled out turned blank when I return to the screen...  Would do RestoreMem solve this and where to put it?

> no just use GSV

Maybe a simple example of filling a client record from a memory form where if it goes through the validate all routine would help if that's not to much to ask.

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Session Values from other user?
« Reply #5 on: February 12, 2009, 05:29:25 AM »
Thanks everybody and cool.

Just a bit of hard work using these p_web.GSV and SSV's all the time.  I guess beggars can't be choosers and I must stop using memory forms!

Charl

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: Session Values from other user?
« Reply #6 on: February 16, 2009, 02:26:07 AM »
Hi Charl,

Memory forms are fine - you just have to remember that memory forms work on _Session_ variables - so you need to work with Session Variables.

The local variables are just there as "place holders" and you should use them sparingly, if at all. When in doubt the session variable is better.

Cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Session Values from other user?
« Reply #7 on: February 16, 2009, 04:38:36 AM »
Yes, now different users input do not get mixed up.

HOWEVER, The same users input does not clear anymore...

1) I checked the PostUpdate code where I use SSV to clear the variables and used a stop to check that the code is executed and the variable cleared.
2) When I go the the form a 2nd time, hey presto, the previous input is back

I still don't have the hang of this. 

I'm feeling very stupid here.  Please?????

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Session Values from other user?
« Reply #8 on: February 16, 2009, 07:14:33 PM »
You should be clearing the SV not the local variable either when you have finished with it or when you open the screen

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Session Values from other user?
« Reply #9 on: February 17, 2009, 02:56:27 AM »
Kevin / Bruce

I modified example web21 to have a memory form (FrameProduct) from where to update the product file.  I left it very simple without trying to put all the SSV and GSV and things since there are only 2 fields.

Could you maybe please put all the right embed's and code so that

1) Different users will work with different 'sets'
2) I do not loose information if I have to alert a message
3) The memory form goes blank the 2nd time a user goes there

I really tried everything but the most practical way is usually an example - somehow I cannot figure NetTalk out the way I figured Clarion out...  And alas, all the language and jargon is going over me.

Thanks
Charl

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: Session Values from other user?
« Reply #10 on: February 18, 2009, 12:52:40 AM »
Hi Charl,

I'm a little confused because you don't explicitly state what you want this example to do.

You've got some code in "Validate Record", which is fine (more on that in a sec) but you're not really saying what your goals are that aren't working.

From the earlier posting I think you're wanting the fields to be cleared when the form is called. So the easiest way to do that is simply to add the fields to the "Priming" tab, and make sure "Prime on Change" is ticked on. (this is a memory form, so it's _always_ in change mode.)

now for a quick comment on your embed code:

      access:Product.open
      PRO:Name = l:Name
      PRO:RRP = l:RRP
      access:Product.insert
      access:Product.close

you should make a call to UseFile after the call to open.
And because this is a server, you should do a TryInsert rather than an Insert.
(Insert may pop up a message window on the server, which is pointless.)

so I'd have

      access:Product.Open()
      access:Product.UseFile()
      PRO:Name = l:Name
      PRO:RRP = l:RRP
      access:Product.TryInsert()
      access:Product.Close()

Cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Session Values from other user?
« Reply #11 on: February 18, 2009, 04:37:59 AM »
Bruce,

Thanks so much!  This is exactly what I wanted to achieve.  I find that "Only if field is not already set" also need to be ticked on when I do some fancy checking with the loc:invalid, etc

Again, thanks.  Now the coding can seriously start, after a few celebratory brandys  :)

Cheers
Charl