NetTalk Central

Author Topic: Session Variable Question  (Read 12161 times)

Mike J

  • Newbie
  • *
  • Posts: 2
    • View Profile
Session Variable Question
« on: June 21, 2007, 06:32:34 AM »
Can a dictionary table's connection string be based on a session variable? I currently have a window's app where the dictionary tables' connection strings are based on global variables since they reside on different DBs. The first level connection string can be hard coded into the web app, but the other levels' connection strings reside in a table and retrieved based on how the user logs in. I would like to use this same approach, but instead of using global variables in the dictionary I would like to use session variables.

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
Re: Session Variable Question
« Reply #1 on: June 21, 2007, 07:21:36 AM »
Mike,

I have not tried this but...

could you put the connection string in a file (tps?) then in the validate imbed of the login form set the tps file and retrieve the correct connection string from the appropriate record. Maybe no session variable needed?

Regards,

Gregg Matteson
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'

ChrisLaurie

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: Session Variable Question
« Reply #2 on: June 21, 2007, 07:22:12 AM »
Hi Mike

AFAIK a session variable can store anything you want - it holds it value relative to the sessions connection.

I have a table called datasets where I store paths (relevant to the sserver). In my login the user must specify the dataset code. In my login form procedure I then look up the dataset and call a SyncDataset procedure that sets the {Prop:Name} of all the relevant tables. It also tries to oepn them and logs errors as well as set a session value and returns the error. If successful it stores the id of the dataset in a session variable the login goes through.

Then in the WebHandler procedure I get the DatasetId session variable and call the SyncDataset procedure and that resets the name for the current request.

I have also successfully parsed the incoming url for the dataset code and worked from there. This however requires some dns magic to make work:
dataset.domain.com

Cheers

Chris

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Session Variable Question
« Reply #3 on: June 21, 2007, 08:41:31 AM »
Hi Mike,

The embed point to use, to set the connection string for tables, is in the WebHandler procedure.

Use the .ProcessLink method, before the "parent" call.

Typically at this point you'll want to check a Session Variable (usually set when the user logs in) to determine what the connection string should be.

Cheers
Bruce

Mike J

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Session Variable Question
« Reply #4 on: June 21, 2007, 10:03:07 AM »
Thanks for the suggestions! I got pulled off of it for a few days, but one of the ideas I'm sure will work. It's nice to have some extra brains to use  :)

Alan Cochran

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Re: Session Variable Question
« Reply #5 on: June 22, 2007, 10:31:03 AM »
Chris,

Do you have sample code that you can send me on how this is done?

Thanks...
Alan

Alan Cochran

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Re: Session Variable Question
« Reply #6 on: June 25, 2007, 08:23:25 AM »
All,

Since using a global variable in the dictionary for File Names doesn't work in the NetTalk web environment (ie !GLO:FileName_CUS), what should I put in the dictionary to handle changing to a different dataset?

TIA,
Alan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Session Variable Question
« Reply #7 on: June 26, 2007, 12:59:38 AM »
Hi Alan,

As long as the variables are THREADED you can use them. Because basically that means that at the start of each thread they are set, and exist (and are "local") for the life of that thread.

So (a) make sure they're threaded.

Then (b)

In WebHandler procedure
.ProcessLink method
Before parent call


GLO:FileName_CUS = p_web.GetSessionValue('userpath') & '\Customer'

Where "userpath" is something you set when the user originally logged in.

cheers
Bruce

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Session Variable Question
« Reply #8 on: June 27, 2007, 01:05:57 AM »
Bruce from what you said here, does this also apply to MSSQL? Do I have to issue any prop:sql Use data base etc?

Cheers,

Kevin

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Session Variable Question
« Reply #9 on: June 27, 2007, 11:28:26 PM »
Hi Kevin,

I'm not the SQL expert, so any others that want to comment, please feel free.

The short answer is that, for SQL, you'd set the "owner" string for each table in the same place.

As I understand it, Clarion doesn't like being connected to 2 different databases at the same time. But I'm a little fuzzy on this bit.
If that is the case then I would suggest using variable table names, and so keeping the data all in one "database" but in separate "tables".

cheers
Bruce



kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Session Variable Question
« Reply #10 on: June 28, 2007, 01:42:30 AM »
Thanks Bruce, 1 database is not an option as the data is already in separate databases. I have written a program that runs through and checks multiple sql databases so I think I had to disconnect and reconnect. I'll give it a go. If not I will just run multiple web server programs unless you think that is a bad idea.

Kev