/    Sign up×
Community /Pin to ProfileBookmark

$_SESSION error!

hi..i wrote this code for when i sign in, it sends another file the id and registers the session…heres the file where i check if the user is a member..

[code=php]
<?php
$sqluser=”select id from members_tbl where username='”.$user.”‘ and password='”.$pass.”‘”;
$resuser=mysql_query($sqluser);
$rowsuser=mysql_num_rows($resuser);
if($rowsuser>0)
{
$rows = mysql_fetch_array($resuser);
$id = $rows[0];
$_SESSION[‘authorized_user’]=true;
echo “<script>location.href(‘../index.php?member=$id’);</script>”;
}

?>
heres the second file where i check if the session is registered…and if it is, i print out the user’s first and last name..

<?php if(isset($_REQUEST[‘member’])){
session_save_path(“sessions”);
session_start();
if(session_is_registered(‘authorized_user’))
{
if($_SESSION[‘authorized_user’]==true)
{
$idd = $_REQUEST[‘member’];
$sqlUser = “select firstname,lastname from members_tbl where id ='”.$idd.”‘”;
$resUser = mysql_query($sqlUser);
$rowUser = mysql_fetch_array($resUser);
$first = $rowUser[0];
$last = $rowUser[1];

echo “<tr><td><center>Welcome $first $last!</td></tr></center>”;
}
}
}
?>[/code]

and finally, it does actually print out the name..but this error comes out as well:

Warning: session_start(): Cannot send session cookie – headers already sent by (output started at c:program fileseasyphp1-7wwwworkbaleishmenu.js:11) in c:program fileseasyphp1-7wwwworkbaleishindex.php on line 50

Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at c:program fileseasyphp1-7wwwworkbaleishmenu.js:11) in c:program fileseasyphp1-7wwwworkbaleishindex.php on line 50

any ideas?..

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleSep 01.2007 — There can not be any html before you call the session_start function. I am assuming that the code you posted for the second page is not the entire script because there is no mention of a javascript file but it is listed in the error message.

Move your PHP code to the top of the page and it should work.
Copy linkTweet thisAlerts:
@mazazinoauthorSep 01.2007 — ya it worked..thanx..
×

Success!

Help @mazazino spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...