Jump to content

Update AP2.0 & PHP5.2 issues to AP2.2 & PHP5.4


Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/274026-update-ap20-php52-issues-to-ap22-php54/
Share on other sites

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;

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;

}

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

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

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.