session variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nmullane
Forum Newbie
Posts: 1
Joined: Thu Aug 18, 2005 8:05 pm

session variables

Post by nmullane »

I'm trying to extract a variable from a string within a session record in a MYSQL database. During a session this is obviously no problem as I can call "$_SESSION['value']['user_id']", however, I am writing a garbage collection routine that will remove records in other tables based on this user id which is in the value array of the session record.

What I need is a parse routine that I can call within the gc function to give me this value ... PHP obviously does this to give me the value in the example above, but I don't think I have access to this from the gc function. The string looks something like this:

value|a:2:{s:7:"user_id";s:2:"5";s:9:"user_type";s:1:"3";}

Any help would be appreciated - or is there an easier way to go about this?

Thanks

Nog.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

I dont know whether I understood you...anyway let me give a go

Code: Select all

foreach($_SESSION["value"] as $key){
	echo $key."<br />";
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

could have swore I posted to this earlier, but I guess not.. Anyways, here's a database session handling system I posted a while ago:

viewtopic.php?t=23781

You should be able to adapt the functions/methods to recreate the session array so you can do whatever calculations you need to against it. :)


For future references, this link can be found in the Useful Posts thread.
Post Reply