mod harbour session js session object

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod harbour session js session object

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: mod harbour session js session object

Post by Otto »

Dear Antonio,
would you be so kind to explain how #xtranslate <matchPattern> => <resultPattern> works.
Does this work on BLOCKS too.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod harbour session js session object

Post by Antonio Linares »

Otto,

Here you have some examples to understand it from apache.prg (mod_harbour)

Code: Select all

   __pp_addRule( hPP, "#xcommand ? [<explist,...>] => AP_RPuts( '<br>' [,<explist>] )" )
   __pp_addRule( hPP, "#xcommand ?? [<explist,...>] => AP_RPuts( [<explist>] )" )
   __pp_addRule( hPP, "#define CRLF hb_OsNewLine()" )
   __pp_addRule( hPP, "#xcommand TEXT <into:TO,INTO> <v> => #pragma __cstream|<v>:=%s" )
   __pp_addRule( hPP, "#xcommand TEXT <into:TO,INTO> <v> ADDITIVE => #pragma __cstream|<v>+=%s" )
   __pp_addRule( hPP, "#xcommand TEMPLATE [ USING <x> ] [ PARAMS [<v1>] [,<vn>] ] => " + ;
                      '#pragma __cstream | AP_RPuts( InlinePrg( %s, [@<x>] [,<(v1)>][+","+<(vn)>] [, @<v1>][, @<vn>] ) )' )
   __pp_addRule( hPP, "#xcommand BLOCKS [ PARAMS [<v1>] [,<vn>] ] => " + ;
                      '#pragma __cstream | AP_RPuts( ReplaceBlocks( %s, "{{", "}}" [,<(v1)>][+","+<(vn)>] [, @<v1>][, @<vn>] ) )' )   
   __pp_addRule( hPP, "#command ENDTEMPLATE => #pragma __endtext" )
function ReplaceBlocks() does the magic for the "{{ ... }}". In fact this function allows you to use any starting and ending characters to replace blocks:

Code: Select all

function ReplaceBlocks( cCode, cStartBlock, cEndBlock, cParams, ... )

   local nStart, nEnd, cBlock
   local lReplaced := .F.
   
   hb_default( @cStartBlock, "{{" )
   hb_default( @cEndBlock, "}}" )
   hb_default( @cParams, "" )

   while ( nStart := At( cStartBlock, cCode ) ) != 0 .and. ;
         ( nEnd := At( cEndBlock, cCode ) ) != 0
      cBlock = SubStr( cCode, nStart + Len( cStartBlock ), nEnd - nStart - Len( cEndBlock ) )
      cCode = SubStr( cCode, 1, nStart - 1 ) + ;
              ValToChar( Eval( &( "{ |" + cParams + "| " + cBlock + " }" ), ... ) ) + ;
              SubStr( cCode, nEnd + Len( cEndBlock ) )
      lReplaced = .T.
   end
   
return If( HB_PIsByRef( 1 ), lReplaced, cCode )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Massimo Linossi
Posts: 474
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: mod harbour session js session object

Post by Massimo Linossi »

Antonio,
is it possible to save sessions data from the mod_harbour code and not inside the HTML ?
like :

Code: Select all

Function Main()
LOCAL nome_utente
use "data" shared new readonly alias infos 
set order to tag CODICE
nome_utente = ""
seek "test"
if found()
     nome_utente = alltrim(infos->NOME)
endif
use
sessionsave(nome_utente)     <---- 
return nil
 
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod harbour session js session object

Post by Antonio Linares »

Massimo,

The PRG code runs on the server, so whatever you may want to save as a session identifier, it will be saved on the server.

You could store the "session" id info in a file, inside a DBF, on a SQL table, etc, but always on the remote server if PRG is being used for it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Massimo Linossi
Posts: 474
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: mod harbour session js session object

Post by Massimo Linossi »

Antonio,
even if I call a javascript that make this ?
[url] https://www.w3schools.com/jsref/prop_win_sessionstorage.asp [/url]
Post Reply