Sessions question

Status
Not open for further replies.

100percentpartytime

New Member
Messages
7
Reaction score
0
Points
0
Hi, I'm trying to make a login page for updating my news database. The tutorial I read told me I needed to do sessions_start(); at the top of my pp script but whenever I put that in I end up with a page that says

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/jokes/public_html/news/index.php:3) in /home/jokes/public_html/news/index.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/jokes/public_html/news/index.php:3) in /home/jokes/public_html/news/index.php on line 4

My script at that area looks like this, where the line "session_start();" is line 4
<?php
session_start();
include 'mydbinfo';
include 'myerrornotification';
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>
I know a common mistake is having a space after the > but I checked and double checked to make sure there isn't one there. I checked the sessions_saving_path() and it said it's set for /tmp so I made that a folder with no luck. Any suggestions to why this isn't working because it's driving me crazy :hahano:!!
 
Last edited:

YamiKaitou

Member
Messages
636
Reaction score
0
Points
16
If you are outputting anything to the file, such as any HTML code, that is why it is failing. session_start() and header() needs to be the first things that are called for them to work correctly
 

100percentpartytime

New Member
Messages
7
Reaction score
0
Points
0
Edit:
hrm, maybe that didn't work. I'm not exactly sure why I can't start a session :/ I even tried copying a very basic script
wait, yes it did work haha. Never mind, thanks a lot!
 
Last edited:
Status
Not open for further replies.
Top