0

Possible Duplicate:
How to fix the session_register() DEPRECATED problem?

I recently moved switched hosts for a site. The site works fine on front end but when I try to login I receieve the following error

Deprecated: Function session_register() is deprecated in /home/content/69/9301569/html/cls.userlogin.php on line 31

Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /home/content/69/9301569/html/cls.userlogin.php:31) in /home/content/69/9301569/html/cls.userlogin.php on line 31

Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/content/69/9301569/html/cls.userlogin.php:31) in /home/content/69/9301569/html/cls.userlogin.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /home/content/69/9301569/html/cls.userlogin.php:31) in /home/content/69/9301569/html/form-login.php on line 14

I didn't build the site; just moved it, So I am quite lost. How would I correct this error?

Community
  • 1
  • 1
Sam
  • 3,410
  • 4
  • 28
  • 48
  • 1
    the web is an ever moving beast, you cant build something, and then move on, anything in active use needs to be maintained. Functions become deprecated, new exploits are found. –  Jul 19 '12 at 20:53

2 Answers2

2

The line it is complaining about will contain a line like this:

session_register("foo");

replace that with:

$_SESSION['foo'] = $foo;

replacing 'foo' and $foo with whatever name is being registered.

Tim Fountain
  • 32,853
  • 5
  • 40
  • 66
  • +1, but you might need to call `session_start()` as well for that to work, depending on the rest of the code. – jeroen Jul 19 '12 at 20:54
  • @Tim I know receive the following error 'precated: Function session_is_registered() is deprecated in /home/content/69/9301569/html/inc.protect.php on line 13 Warning: Cannot modify header information - headers already sent by (output started at /home/content/69/9301569/html/inc.protect.php:13) in /home/content/69/9301569/html/inc.protect.php on line 18' – Sam Jul 19 '12 at 21:04
  • 1
    That you want to replace with `isset($_SESSION['foo'])`, but it sounds like this app needs to be fully tested with a current version of PHP. – Tim Fountain Jul 19 '12 at 21:06
  • I replace `if(!session_is_registered('passed')){ ` with `isset($_SESSION['passed'])` ? – Sam Jul 19 '12 at 21:09
  • @Sam You replace it with `if(!isset($_SESSION['passed'])){`. While we're on this point though, wouldn't it be easier to just find a PHP-savvy friend to go through the code and replace everything? Or use a find/replace function? – Palladium Jul 19 '12 at 21:14
  • Turned out I just had to those two lines. Works like a charm now. – Sam Jul 20 '12 at 02:00
1

you are using a function that was modified in php version from you new server. try deploy app in other server with same version PHP that first

chenio
  • 571
  • 3
  • 10
  • 27
  • Problem is I don't know what the original version of PHP that was being used. – Sam Jul 19 '12 at 21:10
  • @Sam `session_register()` was deprecated in PHP 5.3, so any version before that will work (hopefully, as long as the code doesn't also use 5.3 functions). – Palladium Jul 19 '12 at 21:15