Re: package session vars/ logins



On Oct 15, 7:01 am, Jake <jgarfi...@xxxxxxxxxxxxx> wrote:
Would it be a realistic usage of package vars to hold, for example, a
userid of a current logged in user?

Say, for example, if I had a table of usernames, passwords, and
userids. I could have the person using the application log in and
check their user name and password in a table (basically handling the
login myself). From that point they can access that user's data.
Once the session ends their access to data ends too.

This is how I would do it in PHP/MySql (w/ PHP session vars) or
VB .NET/Sql Server. Not sure if the example translates though, or
would you want a separate Oracle username for each person?

Also, what are some other realistic uses of package vars? thanks.

If the session is persistent (that is, the session is not shared
between different users,) then yes, you can do it that way; though I
would rather use a user-defined session context for this (research
CREATE CONTEXT in the docs.) One good reason for using contexts is
that sys_context() in a query is treated as a bind variable by the CBO
(mostly for efficient FGAC policy implementations, but applies equally
well wherever you use dynamic SQL.) Another good reason is that
contexts are more secure: only single authorized package or procedure
in the database may add or alter values in certain context (for
example, the package where you handle user login - check credentials,
determine access rights, etc.,) while packaged variables can be
altered by the user anytime (don't expect that users will always use
only your front-end to connect to the database, plan for the smartest
of them. :))

Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com

.



Relevant Pages

  • Re: A transactionally consistent view on real-time data with MicroStrategy
    ... Create a context:, ... I tried using a global temporary table for storing a session specific ... and referencing a session specific package global variable in the "AS ... also post it to the MSTR user forums. ...
    (comp.databases.oracle.server)
  • Re: package session vars/ logins
    ... userid of a current logged in user? ... Once the session ends their access to data ends too. ... CREATE CONTEXT in the docs.) ... only single authorized package or procedure ...
    (comp.databases.oracle.server)
  • Re: gnome-session: does not restore session - could be "upgrade bug"
    ... package is broken, usage method unavailable. ... Session is not saved nor is it restored. ... I'm not sure how to diagnose it - gnome-session is a little ... ii libgnomeui-0 2.24.0-0ubuntu1 The GNOME 2 libraries ...
    (Ubuntu)
  • Re: Question on Package Variables
    ... The package spec was as simple as they come; ... package variable can be directly accessed from SQL, ... heard of context switches. ... memory of the other context. ...
    (comp.databases.oracle.server)
  • Re: Perl Inheritance(take-2)
    ... I wanted to reflect the context structure into the code written by ... getting back the the example script, Package1 would be the base class, meaning ... package ContextBase; ... sub addContext { ...
    (perl.beginners)