session php

This is a discussion on "session php" within the PHP Forum section. This forum, and the thread "session php are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 6th, 2004, 08:35
New Member
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
session php

ok in php i have try'ed this standard example
<?php
// page1.php

session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();

// Works if session cookie was accepted
echo '
page 2';

// Or maybe pass along the session id, if needed
echo '
page 2';
?>

ok the sample from php.net
but i get this error when i launch it.

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /usr/local/apache/htdocs/zoli/test.php:9) in /usr/local/apache/htdocs/zoli/test.php

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /usr/local/apache/htdocs/zoli/test.php:9) in /usr/local/apache/htdocs/zoli/test.php Welcome to page #1
page 1
here is a link were i try to run the pages http://www.vibrantday.com/test/text/test.php


Anybody

  #2 (permalink)  
Old Apr 6th, 2004, 08:54
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Sessions use cookies.

You can't have a single line printed to the client otherwise, the headers are sent. You can't send the headers twice.

Cookies must be sent before ANYTHING else in the page because they go in the header. Thus this code will only work if it's the first thing in your document.
  #3 (permalink)  
Old Apr 7th, 2004, 05:49
New Member
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
ok tanks' i found the problem. It was on the configuration filee of php.ini on the server. Tanks a lot
Closed Thread

Tags
session, php

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
are session safe? alexgeek PHP Forum 8 Aug 30th, 2007 10:45
Help with SESSION vars, please? Donny Bahama PHP Forum 3 May 28th, 2007 15:53
Session variables ideleon PHP Forum 2 Feb 7th, 2006 08:04
Session Problems :( benbacardi PHP Forum 8 Jun 1st, 2005 18:51
session problem fender79 Classic ASP 8 May 18th, 2005 02:26


All times are GMT. The time now is 08:28.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43