monkey_05_06 Posted April 17, 2007 Share Posted April 17, 2007 I'm working on a script where I would like a MySQL link identifier to persist over a redirect to another URL. I've tried using session variables to persist the identifier: <?php session_start(); $conn = @mysql_connect("localhost", "username", "pass"); $_SESSION["conn"] = $conn; header("Location: $url"); ?> The variable persists the redirect, but the identifier seems to be getting modified. I know for a fact that it is a valid MySQL link identifier prior to the redirect, however after the redirect it is invalid. Is there any explanation for this??? Link to comment https://forums.phpfreaks.com/topic/47357-mysql-connection-persisting-redirect/ Share on other sites More sharing options...
trq Posted April 17, 2007 Share Posted April 17, 2007 You cannot store a resource within a session. Why do you think you need a persistent connection? Link to comment https://forums.phpfreaks.com/topic/47357-mysql-connection-persisting-redirect/#findComment-231028 Share on other sites More sharing options...
monkey_05_06 Posted April 17, 2007 Author Share Posted April 17, 2007 Hmmm...actually I can think of a way to work around it now that I know it can't be done. Thanks! Link to comment https://forums.phpfreaks.com/topic/47357-mysql-connection-persisting-redirect/#findComment-231036 Share on other sites More sharing options...
trq Posted April 17, 2007 Share Posted April 17, 2007 The question still remains. Why do you think you need this? There is rarely a good reason for trying to do so. Link to comment https://forums.phpfreaks.com/topic/47357-mysql-connection-persisting-redirect/#findComment-231037 Share on other sites More sharing options...
monkey_05_06 Posted April 17, 2007 Author Share Posted April 17, 2007 Because it's 3:15 AM [here]. The more important question is why I would be awake. I guess I just figured it would be easier for me to keep the connection open than having to reopen it. I've got all the pertinent data regarding connecting to MySQL available to both pages...it was really just a matter of lack of experience with PHP...and being extremely tired. I understand now why that line of thinking doesn't really make sense. Link to comment https://forums.phpfreaks.com/topic/47357-mysql-connection-persisting-redirect/#findComment-231040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.