freelanceprogrammers.org Forum Index » PHP

Doubt on Sessions


View user's profile Post To page top
adithya_radha Posted: Fri Jan 13, 2006 12:07 pm


Joined: 11 Jan 2006

Posts: 3
Doubt on Sessions
Hello,
I written simple example to work on "Session Management"
Example code :

<?php
session_start();
if ( !isset($count) )
{
session_register(`count`);
$count = 1;
}
?>
You have seen this page <?=$count;?> times
<?php
$count++;
?>

But I am gettig the following errors :
Warning: session_start(): Cannot send session cookie - headers already sent by
(output started at d:program fileseasyphp1-8wwwadithyases1.php:7) in
d:program fileseasyphp1-8wwwadithyases1.php on line 9

Warning: session_start(): Cannot send session cache limiter - headers already
sent (output started at d:program fileseasyphp1-8wwwadithyases1.php:7) in
d:program fileseasyphp1-8wwwadithyases1.php on line 9
You have seen this page 1 times

And the $count is not gettin incremented.

Plz help in coming over the problem
Thanks in advance
Adithya


Send instant messages to your online friends http://in.messenger.yahoo.com

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
dewebbster Posted: Fri Jan 13, 2006 12:16 pm


Joined: 06 Sep 2005

Posts: 16
Doubt on Sessions
You can do cookies with javascript after sending any content, but not
with php.
Increment the count before any content is sent.
A return character or space before the first php tag is enough to
kill any headers action (redirect or cookies, for example.)

This should work, no?

<?php
session_start();
if ( !isset($count) )
{
session_register(`count`);
$count = 1;
}
$count++;
?>
You have seen this page <?=$count;?> times



-m

On Jan 13, 2006, at 12:07 AM, Adithya Radha wrote:

> Hello,
> I written simple example to work on "Session Management"
> Example code :
>
> <?php
> session_start();
> if ( !isset($count) )
> {
> session_register(`count`);
> $count = 1;
> }
> ?>
> You have seen this page <?=$count;?> times
> <?php
> $count++;
> ?>
>
> But I am gettig the following errors :
> Warning: session_start(): Cannot send session cookie - headers
> already sent by (output started at d:program fileseasyphp1-8www
> adithyases1.php:7) in d:program fileseasyphp1-8wwwadithya
> ses1.php on line 9
>
> Warning: session_start(): Cannot send session cache limiter -
> headers already sent (output started at d:program fileseasyphp1-8
> wwwadithyases1.php:7) in d:program fileseasyphp1-8wwwadithya
> ses1.php on line 9
> You have seen this page 1 times
>
> And the $count is not gettin incremented.
>
> Plz help in coming over the problem
> Thanks in advance
> Adithya
>
>
> Send instant messages to your online friends http://
> in.messenger.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
> PHP Data object relational mapping generator
> http://www.metastorage.net/
>
>
>
> SPONSORED LINKS
> Programming languages Object oriented programming Php developer
> Computer security C programming language Computer programming
> languages
>
> YAHOO! GROUPS LINKS
>
> Visit your group "php-objects" on the web.
>
> To unsubscribe from this group, send an email to:
> php-objects-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>



[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
contact_bee Posted: Fri Jan 13, 2006 3:01 pm


Joined: 17 Jul 2005

Posts: 6
Doubt on Sessions
Hi Adithya,
Your problem, as Michael has mentioned, is most likely due to you
unknowingly sending some data before you start the session. Check to make
sure you don`t have any spaces or carriage returns before the opening php
tag or after the trailing close-tag.

I had this problem when I first used php and it drove me mad for ages before
I read the details of what was happening on a forum somewhere.

I hope that sorts it out.

-----Original Message-----
From: Michael Slavin [mailto:mini@...]
Sent: 13 January 2006 06:17
To: php-objects@yahoogroups.com
Subject: Re: [php-objects] Doubt on Sessions

You can do cookies with javascript after sending any content, but not with
php.
Increment the count before any content is sent.
A return character or space before the first php tag is enough to kill any
headers action (redirect or cookies, for example.)

This should work, no?

<?php
session_start();
if ( !isset($count) )
{
session_register(`count`);
$count = 1;
}
$count++;
?>
You have seen this page <?=$count;?> times



-m

On Jan 13, 2006, at 12:07 AM, Adithya Radha wrote:

> Hello,
> I written simple example to work on "Session Management"
> Example code :
>
> <?php
> session_start();
> if ( !isset($count) )
> {
> session_register(`count`);
> $count = 1;
> }
> ?>
> You have seen this page <?=$count;?> times
> <?php
> $count++;
> ?>
>
> But I am gettig the following errors :
> Warning: session_start(): Cannot send session cookie - headers
> already sent by (output started at d:program fileseasyphp1-8www
> adithyases1.php:7) in d:program fileseasyphp1-8wwwadithya
> ses1.php on line 9
>
> Warning: session_start(): Cannot send session cache limiter -
> headers already sent (output started at d:program fileseasyphp1-8
> wwwadithyases1.php:7) in d:program fileseasyphp1-8wwwadithya
> ses1.php on line 9 You have seen this page 1 times
>
> And the $count is not gettin incremented.
>
> Plz help in coming over the problem
> Thanks in advance
> Adithya
>
>
> Send instant messages to your online friends http://
> in.messenger.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
> PHP Data object relational mapping generator
> http://www.metastorage.net/
>
>
>
> SPONSORED LINKS
> Programming languages Object oriented programming Php developer
> Computer security C programming language Computer programming
> languages
>
> YAHOO! GROUPS LINKS
>
> Visit your group "php-objects" on the web.
>
> To unsubscribe from this group, send an email to:
> php-objects-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>



[Non-text portions of this message have been removed]



PHP Data object relational mapping generator http://www.metastorage.net/
Yahoo! Groups Links
Reply with quote
Send private message
View user's profile Post To page top
bnburns Posted: Fri Jan 13, 2006 8:48 pm


Joined: 12 Feb 2005

Posts: 10
Doubt on Sessions
Check and make sure that you do not have a blank line before the <?php
statement. If you do it is sent as html and no header activity can take
place after that.


-----Original Message-----
From: php-objects@yahoogroups.com [mailto:php-objects@yahoogroups.com]On
Behalf Of Adithya Radha
Sent: Friday, January 13, 2006 12:07 AM
To: php-objects@yahoogroups.com
Subject: [php-objects] Doubt on Sessions


Hello,
I written simple example to work on "Session Management"
Example code :

<?php
session_start();
if ( !isset($count) )
{
session_register(`count`);
$count = 1;
}
?>
You have seen this page <?=$count;?> times
<?php
$count++;
?>

But I am gettig the following errors :
Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at d:program
fileseasyphp1-8wwwadithyases1.php:7) in d:program
fileseasyphp1-8wwwadithyases1.php on line 9

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at d:program
fileseasyphp1-8wwwadithyases1.php:7) in d:program
fileseasyphp1-8wwwadithyases1.php on line 9
You have seen this page 1 times

And the $count is not gettin incremented.

Plz help in coming over the problem
Thanks in advance
Adithya


Send instant messages to your online friends http://in.messenger.yahoo.com

[Non-text portions of this message have been removed]



PHP Data object relational mapping generator
http://www.metastorage.net/



SPONSORED LINKS Programming languages Object oriented programming Php
developer
Computer security C programming language Computer programming
languages


----------------------------------------------------------------------------
----
YAHOO! GROUPS LINKS

a.. Visit your group "php-objects" on the web.

b.. To unsubscribe from this group, send an email to:
php-objects-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


----------------------------------------------------------------------------
----



[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
taujago Posted: Sat Jan 14, 2006 10:17 am


Joined: 04 Sep 2005

Posts: 2
Doubt on Sessions
aall the answer was absolutely right. i have ever found that problem.
and the best way to solve is remove blank space before php tag.
sending any data before session is created is not allowed. and for
addidional for ur script (if u don`t mind to change ur script). try
function "session_is_registered()" for session checking...


--- In php-objects@yahoogroups.com, "Bob Burns" <bnburns@5...> wrote:
>
> Check and make sure that you do not have a blank line before the <?php
> statement. If you do it is sent as html and no header activity can take
> place after that.
>
>
> -----Original Message-----
> From: php-objects@yahoogroups.com [mailto:php-objects@yahoogroups.com]On
> Behalf Of Adithya Radha
> Sent: Friday, January 13, 2006 12:07 AM
> To: php-objects@yahoogroups.com
> Subject: [php-objects] Doubt on Sessions
>
>
> Hello,
> I written simple example to work on "Session Management"
> Example code :
>
> <?php
> session_start();
> if ( !isset($count) )
> {
> session_register(`count`);
> $count = 1;
> }
> ?>
> You have seen this page <?=$count;?> times
> <?php
> $count++;
> ?>
>
> But I am gettig the following errors :
> Warning: session_start(): Cannot send session cookie - headers already
> sent by (output started at d:program
> fileseasyphp1-8wwwadithyases1.php:7) in d:program
> fileseasyphp1-8wwwadithyases1.php on line 9
>
> Warning: session_start(): Cannot send session cache limiter - headers
> already sent (output started at d:program
> fileseasyphp1-8wwwadithyases1.php:7) in d:program
> fileseasyphp1-8wwwadithyases1.php on line 9
> You have seen this page 1 times
>
> And the $count is not gettin incremented.
>
> Plz help in coming over the problem
> Thanks in advance
> Adithya
>
>
> Send instant messages to your online friends
http://in.messenger.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
> PHP Data object relational mapping generator
> http://www.metastorage.net/
>
>
>
> SPONSORED LINKS Programming languages Object oriented programming Php
> developer
> Computer security C programming language Computer programming
> languages
>
>
>
----------------------------------------------------------------------------
> ----
> YAHOO! GROUPS LINKS
>
> a.. Visit your group "php-objects" on the web.
>
> b.. To unsubscribe from this group, send an email to:
> php-objects-unsubscribe@yahoogroups.com
>
> c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
>
>
>
----------------------------------------------------------------------------
> ----
>
>
>
> [Non-text portions of this message have been removed]
>
Reply with quote
Send private message
View user's profile Post To page top
ag_kanedrew Posted: Sun Jan 15, 2006 9:40 am


Joined: 15 Jan 2006

Posts: 1
Doubt on Sessions
Adithya,
yes.., i`m agree for another reasons. You must defined your session path. You
can do it with manual setting in php script, if your php.ini (see from
phpinfo.php session.auto_start >> off) is not authomatic handle.
So.. please add session_path on your script :

<?php
session_path("/temp"); /* for example */
session_start();
if ( !isset($count) )
{
session_register(`count`);
$count = 1;
}
$count++;
?>

try it now...
i hope it`s can help you.

Brian Etheridge <Brian.Etheridge@...> wrote: Hi Adithya,
Your problem, as Michael has mentioned, is most likely due to you
unknowingly sending some data before you start the session. Check to make
sure you don`t have any spaces or carriage returns before the opening php
tag or after the trailing close-tag.

I had this problem when I first used php and it drove me mad for ages before
I read the details of what was happening on a forum somewhere.

I hope that sorts it out.

-----Original Message-----
From: Michael Slavin [mailto:mini@...]
Sent: 13 January 2006 06:17
To: php-objects@yahoogroups.com
Subject: Re: [php-objects] Doubt on Sessions

You can do cookies with javascript after sending any content, but not with
php.
Increment the count before any content is sent.
A return character or space before the first php tag is enough to kill any
headers action (redirect or cookies, for example.)

This should work, no?

<?php
session_start();
if ( !isset($count) )
{
session_register(`count`);
$count = 1;
}
$count++;
?>
You have seen this page <?=$count;?> times



-m

On Jan 13, 2006, at 12:07 AM, Adithya Radha wrote:

> Hello,
> I written simple example to work on "Session Management"
> Example code :
>
> <?php
> session_start();
> if ( !isset($count) )
> {
> session_register(`count`);
> $count = 1;
> }
> ?>
> You have seen this page <?=$count;?> times
> <?php
> $count++;
> ?>
>
> But I am gettig the following errors :
> Warning: session_start(): Cannot send session cookie - headers
> already sent by (output started at d:program fileseasyphp1-8www
> adithyases1.php:7) in d:program fileseasyphp1-8wwwadithya
> ses1.php on line 9
>
> Warning: session_start(): Cannot send session cache limiter -
> headers already sent (output started at d:program fileseasyphp1-8
> wwwadithyases1.php:7) in d:program fileseasyphp1-8wwwadithya
> ses1.php on line 9 You have seen this page 1 times
>
> And the $count is not gettin incremented.
>
> Plz help in coming over the problem
> Thanks in advance
> Adithya
>
>
> Send instant messages to your online friends http://
> in.messenger.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
> PHP Data object relational mapping generator
> http://www.metastorage.net/
>
>
>
> SPONSORED LINKS
> Programming languages Object oriented programming Php developer
> Computer security C programming language Computer programming
> languages
>
> YAHOO! GROUPS LINKS
>
> Visit your group "php-objects" on the web.
>
> To unsubscribe from this group, send an email to:
> php-objects-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>



[Non-text portions of this message have been removed]



PHP Data object relational mapping generator http://www.metastorage.net/
Yahoo! Groups Links







PHP Data object relational mapping generator
http://www.metastorage.net/



---------------------------------
YAHOO! GROUPS LINKS


Visit your group "php-objects" on the web.

To unsubscribe from this group, send an email to:
php-objects-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


---------------------------------






---------------------------------
Yahoo! Photos – Showcase holiday pictures in hardcover
Photo Books. You design it and we’ll bind it!

[Non-text portions of this message have been removed]
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help