Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 2nd, 2005, 09:36 AM
Registered User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ironic session trouble.

I really don't get why this is happening, i have 18 php files that cannot be accessed on my site before you log-in, but the first two display the following warning message :

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/sites/inciter.org.uk/public_html/c++/c_helloworld.php:2) in /home/sites/inciter.org.uk/public_html/c++/c_helloworld.php on line 3

the irony here is that each page calls the session_start() function and check_valid_user() function (that i have created), and works on all but those two pages. i call the session_start at the very top of the page.

can anyone enlighten me as to any possible cause for this warning ; the page is also displayed so in affect it works, but not perfectly lol.

  #2 (permalink)  
Old February 2nd, 2005, 11:06 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

do this on each page:

if(!session_id()){

         session_start();
}


----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
  #3 (permalink)  
Old February 2nd, 2005, 12:42 PM
Registered User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for reply, it didn't work the session_id() returned false and moved on to the session_start().

Would i not have needed to add code to add the session_id() else-where or is this automatic?
  #4 (permalink)  
Old February 2nd, 2005, 01:04 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

session_id() returns the session id and false if it is not set. So if somewhere you have already started the session by session_start, you are bound to have a session_id. If you haven't started it, you don't and thats how it checks it.

Another solution would be to put an @ before every session_start you have.

Edit: or having this line in your pages: error_reporting(0);
----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
  #5 (permalink)  
Old February 2nd, 2005, 01:32 PM
Registered User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hehehe Thank you. Yes '@' works just fine i forgot about suppressing the warnings.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Session IDs Causing Trouble When Webtesting VSTS08 matt.m Visual Basic 2008 Essentials 0 March 20th, 2008 09:52 AM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM
Having trouble with Maintaining Session State kmattera Classic ASP Basics 0 December 7th, 2004 08:47 PM
Please i have had a Trouble hurted Wrox Book Feedback 1 June 28th, 2004 02:18 AM
Trouble with session states wigmo BOOK: Beginning ASP.NET 1.0 2 October 28th, 2003 09:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.