...

View Full Version : php registered user only code



theniccolo
12-06-2010, 12:59 AM
<?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

abduraooft
12-06-2010, 08:59 AM
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?

theniccolo
12-06-2010, 09:11 AM
umm, i can easily put them at the top of all the pages if thats what it takes, i have this

?php

session_name('tzLogin');
session_set_cookie_params(2*7*24*60*60);
session_start();
?>


but only on 1 page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum