| | |
error message with sessions
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 9
Reputation:
Solved Threads: 0
Im getting an error with my website when i try using sessions.
Im new to it so im probably doing something stupid
http://www.bluetipdvd.co.uk/cart.php
error message:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/bluetip/public_html/cart.php:4) in /home/bluetip/public_html/cart.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at /home/bluetip/public_html/cart.php:4) in /home/bluetip/public_html/cart.php on line 5
Can anybody suggest what is wrong with this:
thanks
simon
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<? session_start();
header("Cache-control: private");?>
<title>BlueTipDVD.co.uk - Number 1 site for dvds free delivery on all orders</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="bluetipdvd.css" rel="stylesheet" type="text/css">
<script language="javascript">
function longdescription(ID) {
url = 'proddetail.php?ID='+ID;
window.open(url,'welcome','width=200,height=200');
}
</script>
</head>
Im new to it so im probably doing something stupid
http://www.bluetipdvd.co.uk/cart.php
error message:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/bluetip/public_html/cart.php:4) in /home/bluetip/public_html/cart.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at /home/bluetip/public_html/cart.php:4) in /home/bluetip/public_html/cart.php on line 5
Can anybody suggest what is wrong with this:
thanks
simon
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<? session_start();
header("Cache-control: private");?>
<title>BlueTipDVD.co.uk - Number 1 site for dvds free delivery on all orders</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="bluetipdvd.css" rel="stylesheet" type="text/css">
<script language="javascript">
function longdescription(ID) {
url = 'proddetail.php?ID='+ID;
window.open(url,'welcome','width=200,height=200');
}
</script>
</head>
Hey, symoore22! The problem is that session_start() has to write a cookie to the user's computer, and PHP can't write COOKIES after you start the output because once the HTTP headers are sent, cookies can't be sent. (They are sent in the headers.)
So you just need to put session_start() at the very top of your code--or at least before any browser output.
By the way, I have just finished work on what I think is a really slick PHP session mgmt class that also integrates authentication (password-protecting pages). One major advantage of my session class is you don't have to worry about the session timing out on your users unexpectedly. I plan to post it as an article soon. I'd take some guinee pigs now.
So you just need to put session_start() at the very top of your code--or at least before any browser output.
By the way, I have just finished work on what I think is a really slick PHP session mgmt class that also integrates authentication (password-protecting pages). One major advantage of my session class is you don't have to worry about the session timing out on your users unexpectedly. I plan to post it as an article soon. I'd take some guinee pigs now.
Thanks, boonkoon. I missed that, symoore22. Yes, both your session_start() and any header() lines must be BEFORE you actually output any of the HTML document.
That session mgmt and password protection class and article are ready now at http://www.tgreer.com/class_session_php.html
That session mgmt and password protection class and article are ready now at http://www.tgreer.com/class_session_php.html
![]() |
Similar Threads
- Toshiba IDE1 error message (Windows NT / 2000 / XP)
- MERGED: Hardware/Driver Problems-Error Message (Windows 95 / 98 / Me)
- wupdater.exe error message (Web Browsers)
- Please help with DLL error message! (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: HELP PHP w/SQL FORMS
- Next Thread: Auto Addition Script
| Thread Tools | Search this Thread |
ajax apache api array basic beginner binary body broken cakephp checkbox class cms code cookies cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert interactive ip javascript job joomla js limit link login mail mediawiki menu mlm mobile msqli_multi_query multiple mycodeisbad mysql navigation oop outofmemmory paging parse paypal pdf php procedure query radio ram random recursion regex remote script search server sessions sms source space sql stored subdomain syntax system table tutorial unicode update upload url validator variable video web webapplications websitecontactform xml youtube





