Page 1 of 1
Session not working
Posted: Sun Oct 02, 2005 5:26 am
by winsonlee
I tried implementing session using the following code but it doesnt seems to be working. some one can advise me what went wrong ??
Login.php
Code: Select all
session_start();
$_SESSION['userid'] = $_REQUEST['username'];
HOME.php
Code: Select all
if(isset($_SESSION['userid'])){
echo "<tr><td align=center'><strong><font color='#FFFFFF'>Welcome $_SESSION[userid]</font></strong></td></tr>";
}
Posted: Sun Oct 02, 2005 5:30 am
by mickd
it could be setting but because that html you wrote in home has a few mistakes in it it doent show. btw better to use " for html instead of '. also keep the userid in '.
Code: Select all
echo '<tr><td align="center"><strong><font color="#FFFFFF">Welcome ' . $_SESSION['userid'] . '</font></strong></td></tr>';
edit: also the font tag is being depracated, better to use styles instead.
Posted: Sun Oct 02, 2005 6:49 am
by winsonlee
hmm ..
my session still doesnt seems to be working..
Posted: Sun Oct 02, 2005 7:08 am
by feyd
change your error reporting up to E_ALL. I'm going to bet you have output before the session_start() call. In which case,
viewtopic.php?t=1157
41
Posted: Sun Oct 02, 2005 7:58 am
by shiznatix
i don't see you putting session_start() on the home.php page. if you are going to use a session on any page no matter what you have to put session_start() at the top of it
Posted: Sun Oct 02, 2005 8:42 am
by winsonlee
thanks .. that is helpful.
manage to solve the problem