Jump to content

How to save mysql link resources in the session variable?


deoac

Recommended Posts

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
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.
If you want to do something like that then use a persistant connection mysql_pconnect

However 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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.