Web Connection
Custom session fields
Gravatar is a globally recognized avatar based on your email address. Custom session fields
  Stein Goering
  All
  Jul 17, 2014 @ 10:06am
I have added a number of custom fields to the wwsession table. When using native Fox tables, the default Session object handled the extensions automatically.

But it looks like I'll need to subclass wwSession when switching to SQL system files? I added my custom fields to the SQL tables but they are not being updated ...

I should be able to write the subclass code and then just point to it by redefining WWC_SQLSESSION in the include file, right?

--stein

Gravatar is a globally recognized avatar based on your email address. Re: Custom session fields
  Rick Strahl
  Stein Goering
  Jul 18, 2014 @ 04:23pm

I don't think so. The field 'extensions' are simply maps of the field names of the SQL cursor using SCATTER/GATHER NAME, so if you add the fields to the database they should show up on the oData member. The Fox code does the query directly, the SQL code uses a stored proc but it too does a SELECT * for LocateSession.

Just make sure that if you have Fox and SQL tables that both tables include all the same fields.

+++ Rick ---



I have added a number of custom fields to the wwsession table. When using native Fox tables, the default Session object handled the extensions automatically.

But it looks like I'll need to subclass wwSession when switching to SQL system files? I added my custom fields to the SQL tables but they are not being updated ...

I should be able to write the subclass code and then just point to it by redefining WWC_SQLSESSION in the include file, right?

--stein



Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: Custom session fields
  Stein Goering
  Rick Strahl
  Jul 19, 2014 @ 09:07pm
It wasn't a table structure issue - the SQL version of the wwsession table did include my custom fields.

You're right that the oData member gets populated correctly, but the session object relies on hard coded field references in the Save method to actually update the tables.

IF llIsSession = 1 && Session Exists
THIS.oSQL.Execute(;
"UPDATE wwSession SET " + ;
"SessionId=?loData.SessionId," + ;
"UserId=?loData.UserId," + ;
"FirstOn=?loData.FirstOn," + ;
"LastOn=?loData.LastOn," +;
"Vars=?loData.Vars,"+;
"Browser=?loData.Browser,"+;
"IP=?loData.IP,"+;
"Hits=?loData.Hits " + ;
" WHERE SessionId=?loData.SessionId AND LastOn > '" + TTOC(DATETIME() - THIS.nSessionTimeOut) + "'")
ELSE
THIS.oSQL.Execute("INSERT INTO wwSession (" + ;
"SessionId,UserId,FirstOn,LastOn,Vars,Browser,IP,Hits) VALUES "+;
"(?loData.Sessionid,?loData.Userid,?loData.FirstOn,?loData.LastOn,"+;
"?loData.Vars,?loData.Browser,?loData.IP,?loData.Hits)")
ENDIF

I had to modify the above code in my subclass to accommodate my custom fields.

--stein

I don't think so. The field 'extensions' are simply maps of the field names of the SQL cursor using SCATTER/GATHER NAME, so if you add the fields to the database they should show up on the oData member. The Fox code does the query directly, the SQL code uses a stored proc but it too does a SELECT * for LocateSession.

Just make sure that if you have Fox and SQL tables that both tables include all the same fields.

+++ Rick ---



I have added a number of custom fields to the wwsession table. When using native Fox tables, the default Session object handled the extensions automatically.

But it looks like I'll need to subclass wwSession when switching to SQL system files? I added my custom fields to the SQL tables but they are not being updated ...

I should be able to write the subclass code and then just point to it by redefining WWC_SQLSESSION in the include file, right?

--stein



Gravatar is a globally recognized avatar based on your email address. Re: Custom session fields
  Rick Strahl
  Stein Goering
  Jul 20, 2014 @ 01:55pm
Yes you have to do that.

I guess we could look into using wwSql and SqlBuildUpdateStatement to do figure this out automatically...

+++ Rick ---



It wasn't a table structure issue - the SQL version of the wwsession table did include my custom fields.

You're right that the oData member gets populated correctly, but the session object relies on hard coded field references in the Save method to actually update the tables.

IF llIsSession = 1 && Session Exists
THIS.oSQL.Execute(;
"UPDATE wwSession SET " + ;
"SessionId=?loData.SessionId," + ;
"UserId=?loData.UserId," + ;
"FirstOn=?loData.FirstOn," + ;
"LastOn=?loData.LastOn," +;
"Vars=?loData.Vars,"+;
"Browser=?loData.Browser,"+;
"IP=?loData.IP,"+;
"Hits=?loData.Hits " + ;
" WHERE SessionId=?loData.SessionId AND LastOn > '" + TTOC(DATETIME() - THIS.nSessionTimeOut) + "'")
ELSE
THIS.oSQL.Execute("INSERT INTO wwSession (" + ;
"SessionId,UserId,FirstOn,LastOn,Vars,Browser,IP,Hits) VALUES "+;
"(?loData.Sessionid,?loData.Userid,?loData.FirstOn,?loData.LastOn,"+;
"?loData.Vars,?loData.Browser,?loData.IP,?loData.Hits)")
ENDIF

I had to modify the above code in my subclass to accommodate my custom fields.

--stein

I don't think so. The field 'extensions' are simply maps of the field names of the SQL cursor using SCATTER/GATHER NAME, so if you add the fields to the database they should show up on the oData member. The Fox code does the query directly, the SQL code uses a stored proc but it too does a SELECT * for LocateSession.

Just make sure that if you have Fox and SQL tables that both tables include all the same fields.

+++ Rick ---



I have added a number of custom fields to the wwsession table. When using native Fox tables, the default Session object handled the extensions automatically.

But it looks like I'll need to subclass wwSession when switching to SQL system files? I added my custom fields to the SQL tables but they are not being updated ...

I should be able to write the subclass code and then just point to it by redefining WWC_SQLSESSION in the include file, right?

--stein






Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

© 1996-2024