⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 03-user.sgml

📁 PHPLOB注释详细版 使用模板技术的好帮手 PHP最有用的东东了
💻 SGML
字号:
<!-- $Id: 03-user.sgml,v 1.1.1.1 2000/04/17 16:40:03 kk Exp $ --><sect1>User<p>The user class is an extension (a subclass) of the Sessionclass. It keeps a list of global variable names and provides aset of functions to load and save these variables from and to adatabase. The same restrictions as for session variables applyto user variables.Unlike session variables, user variables are not lost when theuser stops and restarts the browser or moves to a differentworkplace (the session id is then lost and consequently allsession variables are lost, since they are bound to the sessionid).User variables require that the user logs in, because theydepend on the availability of a User id to bind variables tothis id. Thus, User is dependent on Auth.The User class is an extension of the Session class. It has allinstance variables and instance methods of Session, only thatsome are implemented different. This documentation onlydescribes these differences.Note that Session and User can successfully share a single<tt/active&lowbar;sessions/ table in a database due to thedifferent values in the <tt/name/ column.<sect2>Instance variables<p><table><tabular ca="">classname<colsep>Serialization helper: The name of this class.magic<colsep>Not meaningful for User.<rowsep>mode<colsep>Not meaningful for User.<rowsep>fallback&lowbar;mode<colsep>Not meaningful for User.<rowsep>lifetime <colsep>Not meaningful for User; see authentication lifetime in Auth instead.<rowsep>gc&lowbar;time<colsep>Functional, but probably not useful in User.<rowsep>gc&lowbar;probability<colsep>Functional, but should be set to 0 in User.<rowsep>that&lowbar;class<colsep>A classname. User uses this class to store and retrieve data.<rowsep>auto&lowbar;init<colsep>Not meaningful for User.<rowsep>secure&lowbar;auto&lowbar;init<colsep>Not meaningful for User.<rowsep></tabular><caption>Accessible instance variables.</caption></table><table><tabular ca="">pt<colsep>Internal array of names of persistent variables.<rowsep>name<colsep>A tag (name) for the session type.<rowsep>id<colsep>Id of the current session.<rowsep>that<colsep>Container object instance.<rowsep></tabular><caption>Internal instance variables.</caption></table><sect2>Instance methods<p><sect3>Accessible instance methods<p><descrip><tag>register($varname)</tag><p>Works as expected.<tag>unregister($varname)</tag><p>Works as expected.<tag>delete()</tag><p>Works as expected.   <tag>url($url)</tag><p>Not useful with User.<tag>purl($url)</tag><p>Not useful with User.<tag>self&lowbar;url()</tag><p>Not useful with User.<tag>pself&lowbar;url()</tag><p>Not useful with User.<tag>reimport&lowbar;get&lowbar;vars()</tag><p>Works as expected.<tag>reimport&lowbar;post&lowbar;vars()</tag><p>Works as expected.<tag>reimport&lowbar;cookie&lowbar;vars()</tag><p>Works as expected.</descrip><sect3>Internal instance methods<p><descrip><tag>get&lowbar;id()</tag><p>This is only a stub implementation that depends on   the user id provided by the page management functions.   The page management functions will use   <tt/$auth-&gt;auth["uid"]/, which is set up by <tt/Auth/.   <tag>put&lowbar;id()</tag><p>Empty. Not useful with User.<tag>serialize($prefix, &$str)</tag><p>Works as expected.<tag>freeze()</tag><p>Works as expected.<tag>thaw()</tag><p>Works as expected.<tag>gc()</tag><p>Works as expected. You do not want to use it, though.<tag>reimport&lowbar;any&lowbar;vars($arrayname)</tag><p>Works as expected.<tag>start()</tag><p>Initialization function, to be called after object   instantiation. Calls get&lowbar;id() to get the current session id,   creates a database connection, then calls thaw() to load all   session variables. <em/Note:/ gc() activation  is commented out!   Remove the comments if you really want gc with User variables.</descrip><p><sect2>Example<p>Use a subclass to provide the appropriate parameters to youruser variables. Usually your subclass looks like this:<tscreen><code>class My&lowbar;User extends User {  var $classname = "My&lowbar;User"; ## Persistence support    var $that&lowbar;class = "CT&lowbar;Sql";}</code></tscreen>Remember that you have to provide a <tt/DB&lowbar;Sql/ subclass with theparameters needed to access your database.Use the page management functions (see above) to use yourUser subclass. The feature name for user variables is<tt/user/; provide the name of your User subclass as a parameterto the user feature:<tscreen><code>  page&lowbar;open(array("sess" =&gt; "My&lowbar;Session", "auth" =&gt; "My&lowbar;Auth", "user" =&gt; "My&lowbar;User"));</code></tscreen>Use the <tt/register()/ instance method to register variables aspersistent. If <tt/$user/ is your user object, use<tscreen><code>$user-&gt;register("u");</code></tscreen>to make the global variable <tt/$u/ persistent. <tt/$u/ may be ascalar value, an array or an object with persistence supportslots.Do not use the instance methods <tt/freeze()/ and <tt/thaw()/directly, but use the page management functions instead.<em/Note:/ Using default authentication and user variables isgoing to be a problem, because currently <tt/User/ does not doany locking. This is, because the <tt/DB&lowbar;Sql/ has currently noportable locking mechanism.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -