Noob alert!!

I tried to protect some pages with a code I found googling. But since my server was recently moved to a better one, the code stoped working and gives me the error "Fatal error: Call to undefined function session_is_registered() .../protect_page.php on line 3"

I googled it, and I think it's happening because of the version of PHP.
I tried to fix it, but no joy!

I would appreciate if you could help me! I will paste here the code I have.

the code I got on every page I wish to protect
<? include('protect_page.php')?>


<html lang="en-US">
    <meta charset="UTF-8">
    <title>Log in</title>
    <link rel="stylesheet" media="all" href="pwstyle.css" />
function goBack()
    <form name="form1" method="post" action="checkpw.php">
        <div id="container">
            <span id="pass">Password:</span>
            <span id="formfield"><input name="pw" type="text" id="pw"></span>
            <span class="submitbt"><input type="submit" name="submitbt"></span>
            <p><input type="button" value="Back" onclick="goBack()"></p>




// pw is the password sent from the form 

$pw = stripslashes($pw);

// you can make this much more robust by checking against a database in this file at this point

if($pw == 'password1'){
elseif($pw == 'password2'){
elseif($pw == 'password3'){
} else {

Can you help me?

Recommended Answers

All 6 Replies

Member Avatar

For session_is_registered, the manual (http://php.net/manual/en/function.session-is-registered.php):

This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

So, don't use it. You must have been looking at some pretty old tutorials.


Is like


Hello thanks for the reply!
I changed my protect_page.php with if(!isset($_SESSION['pw'])), but now I have a new error: Fatal error: Call to undefined function session_register() in /home/mylemcom/public_html/#/checkpw.php on line 10.
I tried to change session_register("pw"); with $_SESSION["pw"];,it didn't give the error but nothing happened.

What can I do to fix this issue?

Thank you

Why session register?

Why not just: $_SESSION["pw"] = "blah"; and then you can: if(!isset($_SESSION["pw"])) { // }


I'm sorry, but I'm not a coder! I was just following a tutorial I found, and it worked for a couple of years, until now!

So I don't understand the code to fix it myself! I was trying to see if someone could give me some instructions to fix the existing code.

So.. The use of session_register is depreciated.. Instead, use:

$_SESSION['uname'] = "Phorce"; whereas before I might have used session_register("phorce"); i don't know, I never used that function.

Now, everytime you want to check if the session exisits: if(!isset($_SESSION['uname'])) { // } and to output it: print($_SESSION['uname']); I'm sorry but I don't understand what you find so difficult about it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.