Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php registered user only code

    Code:
     <?php
    	if($_SESSION['id'])
    	echo '<h1>Hello, '.$_SESSION['usr'].'! You are registered and logged in!</h1>';
    	else echo '<h1>Please, <a href="demo.php">login</a> and come back later!</h1>';
    	echo 'Should i find a new login'
        ?>
    im trying to use this as a check to see if someone is logged in, is this the right idea, any tips to improve this or anymore info just ask please

    Thanks

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    if($_SESSION['id'])
    Do you have the code to set $_SESSION['id'] in the login page? Do you have a call to function session_start() at the top of all pages?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    umm, i can easily put them at the top of all the pages if thats what it takes, i have this
    Code:
    ?php
    
    session_name('tzLogin');
    session_set_cookie_params(2*7*24*60*60);
    session_start();
    ?>
    but only on 1 page.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •