473,666 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why can't I use session

Hi,

When I run this script:

<?php
session_start() ;
$_SESSION['test'] = "Session er smart";
echo $_SESSION['test'];
?>

I get this error-message:

Warning: session_start() [function.sessio n-start]: Cannot send session
cookie - headers already sent by (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10

Warning: session_start() [function.sessio n-start]: Cannot send session cache
limiter - headers already sent (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10
Session er smart
What is wrong?

Ricki
Jul 17 '05 #1
4 47085
Ricki Susic wrote:
Hi,

When I run this script:

<?php
session_start() ;
$_SESSION['test'] = "Session er smart";
echo $_SESSION['test'];
?>

I get this error-message:

Warning: session_start() [function.sessio n-start]: Cannot send session
cookie - headers already sent by (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10

Warning: session_start() [function.sessio n-start]: Cannot send session
cache limiter - headers already sent (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10
Session er smart
What is wrong?

As the error says: You are sending things before you do your sessionstuff.
Solution: don't. Put you sessionlogic on top of the page.

Regards,
Erwin Moller
Ricki


Jul 17 '05 #2
With total disregard for any kind of safety measures Erwin Moller
<si************ *************** *************** @spamyourself.c om>
leapt forth and uttered:
As the error says: You are sending things before you do your
sessionstuff. Solution: don't. Put you sessionlogic on top of
the page.


Actually you just need to make sure you call session_start() before
any output.
--
There is no signature.....
Jul 17 '05 #3
On Mon, 29 Sep 2003 11:52:27 -0500, Phil Roberts wrote:
<snip!>
Actually you just need to make sure you call session_start() before any
output.


Including whitespace!

--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 17 '05 #4
Ricki Susic wrote:

Hi,

When I run this script:

<?php
session_start() ;
$_SESSION['test'] = "Session er smart";
echo $_SESSION['test'];
?>

I get this error-message:

Warning: session_start() [function.sessio n-start]: Cannot send session
cookie - headers already sent by (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10

Warning: session_start() [function.sessio n-start]: Cannot send session cache
limiter - headers already sent (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10
Session er smart

You can't send anything to the browser before starting your session, not even a
single blank line or space. Make sure your file starts like this:

-------------Start of file---------------------
<?PHP
session_start() ;

Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4575
by: Rea | last post by:
Hi! I've searched high and low for this on the net but stil haven't found an answer. I'm trying to install both postnuke and xoops on a win2k server with php 4.3.3. and mysql installed. Both applications are loading terribly slow. When the page finally has been rendered I got the following error:
10
3500
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much more time I have on a session? If I do a refresh, does reset the session clock? Do you have have to go to another page to reset the session timeout or will a postback also do it? This is important as we have a few pages that a user
9
9772
by: charliewest | last post by:
Hello - I have images saved in my SQL SERVER 2000 database. Using ASP.NET (C#) is there any way to temporarily save an image to a session object, and after running some other operations, later retrieve the image from the session object, convert it back to an image, and re-save it to the database? Thanks?
14
2369
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and User B has access to 5, now when both of us hits to the server at the same time then their session variables gets mixedup means either User A and USer B will have now 5 companies or both have 10 companies. Now again when User A hits to the server...
2
14682
by: lookee | last post by:
Hello all, I have simple PHP application that on one page strarts session and write some information to it. On another page program tryes to fetch information from a third page using cURL. On that third page program needs to retrive information that were written to the session and use them. Problem is that when I call the third page and call session_start() it starts a new session where there are no infromation I need. Code below. ...
0
2471
by: TRB_NV | last post by:
I'd been using an Access database based shopping cart, but wanted to change it so that it would use session variables. I have a form that's submitted to a page called addtocart.asp that contains the following information: intProdID -- ProductID strProdName -- Product Name intQuant -- Quantity intProdPrice -- Price productType -- Type of product (ie. Wine, Cheese, etc...)
11
13164
by: Bocah Sableng | last post by:
Hi, I'm new member of this group. I had added new virtual host at my intranet server. The new virtual host configuration on httpd.conf is similar with the old one. At the new virtual host, the session id seems changed every interaction to server (new page or reload). The old one is fine, the session id keeps at the same string. Both are at the same server. I use Apache 2.2.3 (Win32) with PHP 5.2.0.
11
2343
by: Sylvia A. | last post by:
How can I define global classes in web application ? Classes can be set to session variables ? Thanks
11
26599
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package and PEAR is in c:\wamp\php\pear I modified php.ini in the c:\wamp\php directory to reflect the actual path, but even stopping and restarting my server shows the c: \php5\pear path. I can't change it no matter what I do I also tried the...
7
2023
by: gowthamkg | last post by:
For the following code when ever i open the this page the text box has / i ahve set the value of text box with session variables whic is exuted only when submit button is clicked....Pls Help me.... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.