Page 1 of 2

[SOLVED] Warning: session_start(): Cannot send session cooki

Posted: Fri Jun 24, 2005 4:27 pm
by microshaft
HI,

I have looked at all the forums and i seem to be doing all they ask but i still get the following message

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\rivaaz\index.php:1) in c:\inetpub\wwwroot\rivaaz\index.php on line 1

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\rivaaz\index.php:1) in c:\inetpub\wwwroot\rivaaz\index.php on line 1

the follwing is php code which contains all the session stuff. also i have a inlude language file
---------- index.php---------------------------------------------------

Code: Select all

<?session_start();

if (!isset($_REQUEST['lang']))
{
$def_lang="en";
session_register("user_lang");
$HTTP_SESSION_VARS['user_lang']=$def_lang;
}
else
{
$HTTP_SESSION_VARS['user_lang']=$_REQUEST['lang'];

}
include("inc/langs/lang.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>RIVAAZ</title>
-------------include language file lang.php--------------------------------

Code: Select all

<?

if ($_SESSION['user_lang']=="en")
{
$home="HOME";
$collection="COLLECTION";
$about="ABOUT";
$contact="CONTACT";
}
?>
most of the forums suggest having the start_session at the top . Ive tired changing it around but no luck.

im using php4.3 os win xp with iis 4

i hope some one can guide me where im going wrong

Posted: Fri Jun 24, 2005 4:42 pm
by shiznatix
output buffering. quick fix - ob_start but this is a bad way to do it

Posted: Fri Jun 24, 2005 4:44 pm
by microshaft
im sorry im kinda new to all this where do i place the ob_start() function

Posted: Fri Jun 24, 2005 5:01 pm
by dethron
Do you see something missing? :)

Code: Select all

<?session_start();
i think

Code: Select all

<?php session_start();
is better line to replace your first.

Posted: Fri Jun 24, 2005 5:01 pm
by shiznatix
first line put ob_start();

Posted: Fri Jun 24, 2005 5:08 pm
by microshaft
dethron wrote:Do you see something missing? :)

Code: Select all

<?session_start();
i think

Code: Select all

<?php session_start();
is better line to replace your first.

tried that same error message

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\rivaaz\index.php:1) in c:\inetpub\wwwroot\rivaaz\index.php on line 1

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\rivaaz\index.php:1) in c:\inetpub\wwwroot\rivaaz\index.php on line 1

Posted: Fri Jun 24, 2005 5:09 pm
by dethron
and if you still have problem after replacing as i suggested, may be the reason you are using Macromedia Dreamweaver MX as your text ediyor. ;)

Posted: Fri Jun 24, 2005 5:11 pm
by microshaft
shiznatix wrote:first line put ob_start();

tried that too

Code: Select all

<?php ob_start(); 
session_start();

if (!isset($_REQUEST['lang']))
{
$def_lang="en";
session_register("user_lang");
$HTTP_SESSION_VARS['user_lang']=$def_lang;
}
else
{
$HTTP_SESSION_VARS['user_lang']=$_REQUEST['lang'];

}
include("inc/langs/lang.php");
?>
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\rivaaz\index.php:1) in c:\inetpub\wwwroot\rivaaz\index.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\rivaaz\index.php:1) in c:\inetpub\wwwroot\rivaaz\index.php on line 2

Sorry same error message

Posted: Fri Jun 24, 2005 5:14 pm
by dethron
are you using Macromedia Dreamweaver MX?

Posted: Fri Jun 24, 2005 5:14 pm
by shiznatix

Code: Select all

<?
ob_start(); 
session_start();
 
if (!isset($_POST['lang']))//or $_GET['lang']
{
$def_lang="en";
$_SESSION['user_lang'] = $def_lang;
}
else
{
//use get OR post instead of request
$_SESSION['user_lang'] = $_POST['lang'];//or get $_GET['lang'];
 
}
include("inc/langs/lang.php");
?>
try that

Posted: Fri Jun 24, 2005 5:16 pm
by microshaft
dethron wrote:and if you still have problem after replacing as i suggested, may be the reason you are using Macromedia Dreamweaver MX as your text ediyor. ;)

i used dreamweaver initially, but i have been coding the php using Ultraedit.
but how would dreamweaver screw it up

Posted: Fri Jun 24, 2005 5:19 pm
by dethron
since first you have created the file using Dreamweaver, the file has some special characters that prvent session to start.

you can use vi editor to see them in linux, or homesite in windows.

if you dont have one of them, let me know, and i will tell you what to do...

Posted: Fri Jun 24, 2005 5:23 pm
by microshaft
dethron wrote:since first you have created the file using Dreamweaver, the file has some special characters that prvent session to start.

you can use vi editor to see them in linux, or homesite in windows.

if you dont have one of them, let me know, and i will tell you what to do...
sorry dont have any of those

Posted: Fri Jun 24, 2005 5:28 pm
by dethron
since you dont have vi editor, and most *nix common installations have this editor, i assume you are using windows.

go to command line (cmd OR command) and run edit (classical windows editor).

at the beginning you will see some nasty characters ;)

good luck...

Posted: Fri Jun 24, 2005 5:35 pm
by microshaft
dethron wrote:since you dont have vi editor, and most *nix common installations have this editor, i assume you are using windows.

go to command line (cmd OR command) and run edit (classical windows editor).

at the beginning you will see some nasty characters ;)

good luck...

YOUR A STAR D thanks alot it worked. i hated frontpage but i think im gona add dreamweaver to my list

Thanks again