jvrothjr Posted February 4, 2013 Share Posted February 4, 2013 I have been asked to update are software we are running I have been able to get the new versions update running but am having issues with SESSION_REGISTER and declaring session variables. can someone just point me in the right direction. I have seem sessions_reg goes away in php 5.6 so any help to switch now would be great. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted February 4, 2013 Share Posted February 4, 2013 As you noticed session_register () is indeed deprecated, but the solution is quite easy. Just save the values to the $_SESSION superglobal instead, and it will automatically be saved to the session file by the PHP parser. As shown in the PHP manual. Example: // Assuming we have this variable. $username = "test"; // Instead of this. session_register ("username"); // Do this. $_SESSION['username'] = $username; Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted February 5, 2013 Author Share Posted February 5, 2013 so replace if (substr($_SERVER['HTTP_REFERER'],-10) <> "header.php") {$_SESSION[referer] = $_SERVER['HTTP_REFERER'];} with if (substr($_SERVER['HTTP_REFERER'],-10) <> "header.php") { $referer = $_SERVER['HTTP_REFERER']; $_SESSION[referer] = $referer; } Quote Link to comment Share on other sites More sharing options...
Christian F. Posted February 5, 2013 Share Posted February 5, 2013 You don't need the interim $referer variable there, just set it directly from $_SERVER['HTTP_HEADER']. So the first line is indeed correct. You also need to have quotes around the index in the $_SESSION array, otherwise PHP will think that you're attempting to use a constant and not a string. As a little nit-picking, you should be using != to test for inequality. As that's what's expected. I know that <> works in MySQL, but not sure if it does in PHP (never tested). Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted February 5, 2013 Author Share Posted February 5, 2013 ok used but still getting error if (substr($_SERVER['HTTP_REFERER'],-10) != "header.php") {$_SESSION[referer] = $_SERVER['HTTP_REFERER'];} Notice: Use of undefined constant referer - assumed 'referer' in C:\wamp\apps\testrequest\includes\pconvar.inc on line 2 Quote Link to comment Share on other sites More sharing options...
Christian F. Posted February 5, 2013 Share Posted February 5, 2013 See the first sentence of the second paragraph in my last post. Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted February 5, 2013 Author Share Posted February 5, 2013 fixed it right after I posted sorry Next issue Notice: Undefined index: cmd in C:\wamp\apps\testrequest\index.php on line 253 switch($_REQUEST['cmd']){ 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.