ad_set_client_property (public)

 ad_set_client_property [ -clob clob ] [ -secure secure ] \
    [ -persistent persistent ] [ -session_id session_id ] module name \
    value

Defined in packages/acs-tcl/tcl/security-procs.tcl

Sets a client (session-level) property. If -persistent is true, the new value will be written through to the database (it will survive a server restart, bit it will be slower). If -secure is true, the property will not be retrievable except via a validated, secure (HTTPS) connection.

Switches:
-clob (defaults to "f") (optional)
tells us to use a large object to store the value
-secure (defaults to "f") (optional)
-persistent (defaults to "t") (optional)
-session_id (optional)
controls which session is used
Parameters:
module - typically the name of the package to which the property belongs (serves as a namespace)
name - name of the property
value - value if the property

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 test_client_properties client_properties (test acs-tcl) ad_set_client_property ad_set_client_property test_client_properties->ad_set_client_property ad_conn ad_conn (public) ad_set_client_property->ad_conn ad_log ad_log (public) ad_set_client_property->ad_log db_dml db_dml (public) ad_set_client_property->db_dml db_exec_plsql db_exec_plsql (public) ad_set_client_property->db_exec_plsql db_map db_map (public) ad_set_client_property->db_map Class ::xowiki::Mode Class ::xowiki::Mode (public) Class ::xowiki::Mode->ad_set_client_property ad_cache_returnredirect ad_cache_returnredirect (public) ad_cache_returnredirect->ad_set_client_property apidoc::set_public apidoc::set_public (private) apidoc::set_public->ad_set_client_property apm_get_package_repository apm_get_package_repository (private) apm_get_package_repository->ad_set_client_property ds_replace_get_user_procs ds_replace_get_user_procs (private) ds_replace_get_user_procs->ad_set_client_property

Testcases:
client_properties
Source code:

    if { $secure != "f" && !([security::secure_conn_p] || [ad_conn behind_secure_proxy_p])} {
        error "Unable to set secure property in insecure or invalid session"
    }

    if { $session_id eq "" } {
        set session_id [ad_conn session_id]
    }

    if { $session_id eq "" } {
        ad_log warning "could not obtain a session_id via 'ad_conn session_id'"
    } else {

        if { $persistent == "t" } {
            # Write to database - either defer, or write immediately. First delete the old
            # value if any; then insert the new one.

            set last_hit [ns_time]

            if { $clob == "t" } {

                db_transaction {

                    # DRB: Older versions of this code did a delete/insert pair in an attempt
                    # to guard against duplicate insertions.  This didn't work if there was
                    # no value for this property in the table and two transactions ran in
                    # parallel.  The problem is that without an existing row the delete had
                    # nothing to lock on, thus allowing the two inserts to conflict.  This
                    # was discovered on a page built of frames, where the two requests from
                    # the browser spawned two AOLserver threads to service them.

                    # Oracle doesn't allow a RETURNING clause on an insert with a
                    # subselect, so this code first inserts a dummy value if none exists
                    # (ensuring it does exist afterwards) then updates it with the real
                    # value.  Ugh.

                    set clob_update_dml [db_map prop_update_dml_clob]

                    db_dml prop_insert_dml ""

                    if { $clob_update_dml ne "" } {
                        db_dml prop_update_dml_clob "" -clobs [list $value]
                    } else {
                        db_dml prop_update_dml ""
                    }
                }
            } else {
                #
                # Perform an upsert operation via stored procedure
                #
                db_exec_plsql prop_upsert {}
            }
        }
    }

    # Remember the new value, seeding the memoize cache with the proper value.
    util_memoize_seed [list sec_lookup_property $session_id $module $name] [list $value $secure]
Generic XQL file:
<fullquery name="ad_set_client_property.prop_insert_dml">
    <querytext>
	insert into sec_session_properties
	  (session_id, module, property_name, secure_p, last_hit)
	select :session_id, :module, :name, :secure, :last_hit
        from dual
        where not exists (select 1
                          from sec_session_properties
                          where session_id = :session_id and
                          module = :module and
                          property_name = :name)
      </querytext>
</fullquery>
packages/acs-tcl/tcl/security-procs.xql

PostgreSQL XQL file:
<fullquery name="ad_set_client_property.prop_update_dml">
    <querytext>
        update sec_session_properties
        set property_value = :value,
          secure_p = :secure,
          last_hit = :last_hit
        where session_id = :session_id and
          module = :module and
          property_name = :name
      </querytext>
</fullquery>

<fullquery name="ad_set_client_property.prop_upsert">
    <querytext>
    select sec_session_property__upsert(:session_id, :module, :name, :value, :secure, :last_hit) from dual
  </querytext>
</fullquery>
packages/acs-tcl/tcl/security-procs-postgresql.xql

Oracle XQL file:
<fullquery name="ad_set_client_property.prop_update_dml_clob">
    <querytext>
         update sec_session_properties
         set property_value = null,
           property_clob = empty_clob(),
           secure_p = :secure,
           last_hit = :last_hit
         where session_id = :session_id and
           module = :module and
           property_name = :name
         returning property_clob into :1
      </querytext>
</fullquery>

<fullquery name="ad_set_client_property.prop_update_dml">
    <querytext>
         update sec_session_properties
         set property_value = :value,
           property_clob = null,
           secure_p = :secure,
           last_hit = :last_hit
         where session_id = :session_id and
           module = :module and
           property_name = :name
      </querytext>
</fullquery>

<fullquery name="ad_set_client_property.prop_upsert">
    <querytext>
      begin
         sec_session_property.upsert(:session_id, :module, :name, :value, :secure, :last_hit);
      end;
      </querytext>
</fullquery>
packages/acs-tcl/tcl/security-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: