deoac Posted May 10, 2006 Share Posted May 10, 2006 When I make a mysql connection on one page of my site, I want to save the resource in the $_SESSION variable, and then use the resource on the next page. Unfortunately, after a session_start, the mysql resource is gone. Other variable types are saved properly in the $_SESSION.Any ideas on how I can accomplish this?Thanks,Shimon Quote Link to comment Share on other sites More sharing options...
ober Posted May 10, 2006 Share Posted May 10, 2006 I'm not quite clear on why you would want to re-use the same resource. It's not going to contain the same recordset if that's what you're trying to do.Besides, you have to reconnect to the database on the new page, so it can't re-use the same identifier. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 10, 2006 Share Posted May 10, 2006 If you want to do something like that then use a persistant connection mysql_pconnectHowever with a persitant connection you are in danger of hitting your maximum database connections limit, therefore your site goes down until all the persistant connections are closed. Quote Link to comment Share on other sites More sharing options...
trq Posted May 11, 2006 Share Posted May 11, 2006 Resource objects (ie connections) cannot be safely serialized and thus cannot be saved in sessions. Why you would ever want to try this in the first place is behond me, it is an invaluable waste of resources. Quote Link to comment Share on other sites More sharing options...
deoac Posted May 14, 2006 Author Share Posted May 14, 2006 Thanks for everyone's assistance. My goal is to not have to reconnect to the mysql server on every page. We've don't want to be limited to a small number of persistent connections. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.