Re: PEAR and PHPLib compatibility?

From: Date: Fri, 12 Mar 2004 14:47:33 +0000
Subject: Re: PEAR and PHPLib compatibility?
References: 1 2 3 4 5 6  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11266@lists.php.net to get a copy of this message
Marko wrote:
Hi Lukas,
No, storing of non authentication and permission related things is not on the feature list. There is a patch pending for commit which will allow attaching other data to the user, like email etc from the admin API.
ok, now I eventually got it. So that is a substantial difference in functionality between LiveUser and phplib's session managment! That answers my questions and I now understand that I did not simply miss the point in the description: it simply doesn't exist at all... :) ok
Ok, I think I can help out with this question. In PHP3 IIRC, there were no 'sessions' natively. So PHPLib implmented sessions and session variables. In PHP4 and later, session variable support was added natively to the core of PHP. So, if you need to store a session variable, just register that variable as a session variable using PHP4's built-in session. Management. Somewhere near the top of your code (before any output might be sent to the browser), call session_start(). Then, use the $_SESSION superglobal array. $_SESSION['zipcode'] = "44555"; echo $_SESSION['zipcode']; Now, these session variable are attached to the client browser session, not stored persistantly in the DB attached to the user. My only suggestion for how to store stuff persistantly that is associated with the user, would be to set up your own table(s) in your database, and do the storing/retrieval yourself. There should be a way to get some sort of UID from LiveUser, I think (I hope anyhow - I plan to do something like this myself). If you can get a UID, your table could look something like: --------------------------------- | UID | zipcode | telephone | --------------------------------- | 187 | 44555 | (555) 123-4567| --------------------------------- This has the downside that you have to 'predefine' all the user variables you want. Alteratively you could do something like have a table with two fields: the UID field as above (to associate the data with the user), and a large-text field, like a BLOB. PHP has a function called 'serialize' that will create a string representation of a variable (it works for arrays, and even objects, but there are some gotchas for the objects, so read the documenation for serialze from the php manual). You could create your own $user_vars[] array and store all the vars you want to store for that user inside the array, then serialize() the array and store the resultant string in the database. Then, on each page load, you would retrieve that string and call unserialize() on the string to get your array back. Just some ideas. Hope they help. Jeff Schmidt

« previous php.pear.general (#11266) next »