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
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;

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.