Jump to content

Trouble with session_start();


PigsHidePies

Recommended Posts

My current problem has to do with session_start();
I am trying to add this to the top of all my pages. I have it working on my login.php page fine. For some reason though on index.php instead of it working I get two of the same messages/links at the very top of the page: "function.session-start"
The rest of the page shows up, but it messes up the structure.
When I click on either of the above comments I get:
"Not Found
The requested URL /function.session-start was not found on this server."
Basically what I am trying to do is check if a user is logged in or not by using: if(isset($_SESSION['validuser'])).
Any help is appreciated.
Link to comment
Share on other sites

[code]
<?php
session_start();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html>

<head>

<title>help me ahhh</title>



<link rel=stylesheet href="style.css" type="text/css">



</head>







<body>



<div id="shaper">






<div id="headerholder">

<div id="leftheader">

<img src="header.jpg" border="0"></img>

</div>

<div id="rightheader">


<?php
if (!isset($_SESSION['valid_user']))
{
echo '<form name="input" action="login.php"

method="post">

username

<input type="text" name="username" maxlength=12 class="textbox">

<br />



password

<input type="password" name="password" maxlength=12 class="textbox">

<br />

<input type="submit" value="login" class="submit">

</form>';
}
?>

...more html...
</body>
</html>[/code]
Link to comment
Share on other sites

might be the way you format html code and white spaces



[code]
<?php session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>

<title>help me ahhh</title>


<link rel=stylesheet href="style.css" type="text/css">

</head>

<body>

<div id="shaper">

<div id="headerholder">

<div id="leftheader">

<img src="header.jpg" border="0"></img>

</div>

<div id="rightheader">


<?php

if (!isset($_SESSION['valid_user']))
{
?>

<form name="input" action="login.php" method="POST">

username

<input type="text" name="username" maxlength=12 class="textbox">

<br>

password

<input type="password" name="password" maxlength=12 class="textbox">

<br>

<input type="submit" value="login" class="submit">

</form>';

<?}?>
...more html...
</body>
</html>
[/code]
Link to comment
Share on other sites

Still not working,heres the warning messages:



<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /var/www/index.php:1) in <b>/var/www/index.php</b> on line <b>1</b><br />
<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /var/www/index.php:1) in <b>/var/www/index.php</b> on line <b>1</b><br />
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.