drkstr Posted August 12, 2006 Share Posted August 12, 2006 Hello!I apologize if my question might seem a bit basic. I am about a day and half into learning how to do all this web development stuff, so I am a newbie to the 10th power. Luckly, I do have a little bit of a background in programming so I am not completly lost. :)Here is what I am trying to do:I need to direct the user to another php script but keep the same sate of my "user" object.Here is what I've tried: (psuedo code)[code]$currentUser = new User(); # <snipped out irelevent code>$query = urlencode( serialize($currentUser) );header( "Location:index.php?user=$query" );[/code]now it will forward to index.php just fine, and I see the serialized url version of my object in the title bar, but I'm not sure how to grab it from the url.I've tried both $_GET['user'] and $_SERVER['QUERY_STRING'] to retrieve the data, but they return empty strings. I have not been able to find the answer in my PHP book, google, or in RFC 2616. Part of the problem is I don't really know what to look for. Can any one point me in the right direction?Thanks in advance!...aaron Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 12, 2006 Share Posted August 12, 2006 when this goes to a new pagedoes the index.phphave the full information in the urlwww.example.com/index.php?user=onlyicanFor example Quote Link to comment Share on other sites More sharing options...
drkstr Posted August 12, 2006 Author Share Posted August 12, 2006 Thanks for the quick reply!It appears that it does. I'm not positave though since a serialized object is so cryptic. Here is the text in the url bar after the forward:[code]http://localhost:18881/index.php?user=O%3A4%3A%22User%22%3A3%3A%7Bs%3A12%3A%22%00User%00myName%22%3Bs%3A5%3A%22admin%22%3Bs%3A12%3A%22%00User%00myPass%22%3Bs%3A34%3A%22%241%24CsiOMyoi%24Lad1yieZJohpdTwvGcdG0.%22%3Bs%3A19%3A%22%00User%00myLoginStatus%22%3Bb%3A1%3B%7D[/code]**edit**The reason why I mentioned the RFC earlier was because I thought it might be possible to modify the http header to make it think that a get request was sent. The book that I have been reading states that the $_GET['item'] array only works when a get request was submitted (which I am assuming why my string is Null when I try to access it).Unfortunatly, the RFC was a little bit to technical for me :-\Does anyone know how to use the header function to make my php script think a get request was submitted? Or is there a better way to make this variable populate?thanks! Quote Link to comment Share on other sites More sharing options...
drkstr Posted August 13, 2006 Author Share Posted August 13, 2006 Sorry to double post.I've been able to resolve the original problem by using the "session" functions to store the object in a temporary file. However, I would prefer to be able to pass the data though the url if it's even possible.Thanks for your time!...aaron Quote Link to comment Share on other sites More sharing options...
drkstr Posted August 25, 2006 Author Share Posted August 25, 2006 Solved.Forgot to use urldecode($string) before using unserialize($decoded_string).regards,...drkstr*edit*but I'm not going to do it this way anyways. After learning a little bit more about PHP, I can see that $_SESSION variables is a much better way to go about it. 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.