473,758 Members | 5,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

session data / header question?

201 New Member
hello -

if session is started from the same page, and i have another script that needs to access header data with out destorying the session data.

a. should i store the header info in variables on the page then access them by the var in the page that needs them?

error desc:

currently if the session has started and that script is executed it resends the header info which appearantly destroys the session and errors "saying headers alread sent".

thanks in advance for your help.

theo e. werntz ii
Jan 15 '10 #1
9 2379
Atli
5,058 Recognized Expert Expert
Hey.

I think you may be misunderstandin g how headers and sessions work. Or I may be misunderstandin g your post. Either way, this is how session do work.

A session has little to do with the actual headers. It only sends a session ID via a cookie (or in rare cases a GET parameter, but that is irrelevant here) - which is why it must be able to set a header. If you call session_start() again from within the same PHP page, or any PHP page included into that page, then it would have no effect.

If - after said page has been sent and the cookie has reached the client - the client does another request (via AJAX, for example) the session ID int the cookie will be sent to the server and the previously used session will be restored.

If you are getting a "headers already sent" warning and you session data is not being set, then odds are that your first call to session_start is failing. That error means that the headers can not be set because they have already been sent to the client, meaning the session cookie can not be sent.
Jan 15 '10 #2
wizardry
201 New Member
thanks for the reply -

here are the errors:

cannot send session cookie - headers already sent by
cannot send session cache limiter - headers already sent by

i have an a script that is loaded from when it is first access.

i.e. www.domain.com -- loads then the script loads when its is threaded.

then the session server will start once the login form has been accessed on the same page.

i've tried adding that below the session marker but it gets the same error. meaning have the session loaded first on the page.

i know that session is working correctly, im able to access objects with that session data.

-- also not to get off topic do you have a good article on cookies?

thanks in advance for your help.
Jan 15 '10 #3
wizardry
201 New Member
also the page that im having the problem is the index. the rest of the pages that i need that script on and they use sessions are working fine.

thanks, again in advance for your help!
Jan 15 '10 #4
nilayanand
10 New Member
Just make sure, you do not output anything before calling session_start() .
Jan 16 '10 #5
wizardry
201 New Member
nothing was outputed before the session start.

session start is at the begining of the page.

i.e.
Expand|Select|Wrap|Line Numbers
  1. if (!isset($_Session))
  2. {
  3. session_start();
  4. }
  5. ?>
  6. <!-- here is the script to be called after. -->
  7. <?php require_once('script.php'); ?>
  8.  
  9. -- html / and css -- not posting not needed for this debugging help.
  10.  
Ok as i posted earlier this way works on the rest of the site. excluding the INDEX.php

my question is why has it worked on all of the other pages but not the INDEX.php

i've tried moving the session_start module to the top or where the function needs it. but nothing. same issue. i've tried putting the script that needs to be ran before or after the session call to start. but same error.

Session do work. I use them and are able to output their variables on a echo "$_session" ;

thanks, again in advance for your help.

Theo Werntz II
Jan 16 '10 #6
Atli
5,058 Recognized Expert Expert
Hey.

The session super-global is called $_SESSION, not $_Session or $_session, or any other variation thereof. It has to be all upper-case. (Variable names in PHP are case-sensitive.)

If you use the incorrect case PHP will just treat it as a typical variable, and create a normal array for you. It will work just fine on that page, but won't be stored between requests.
Jan 16 '10 #7
wizardry
201 New Member
hey alti -

its not the variable case size. it is in case upper format.

could you re-read the previous post?

have you ran into any problems with index.php with using sessions?

sessions work through out the rest of the site? but not the index for this script. it works fine with out it but not with it added.


Thanks, in advance for your help!
Jan 16 '10 #8
Atli
5,058 Recognized Expert Expert
@wizardry
I only mentioned that because your example code used a mixed-case version of it, which would be invalid.
In any case, if you are sure this is not the problem, I'm inclined to agree with nilayanand.

Can you post the entire beginning of the index.php, up to the point you call the session_start function?
The "headers already sent" error tells us there is something being sent to the browser before the function is called. We must find out what and remove it.

You can check out this article draft which Markus has been working on. It explains this problem in details.

@wizardry
It's Atli, by the way ;-)
(It seems most people want to put the L first. I don't know why xD)
Jan 17 '10 #9
wizardry
201 New Member
thanks for the reply atli -

ok the code is their nothing else was copied besides where i was having the error.

i'm doing some more debugging.

thanks again for your help. will repost later currently working on this img loop array problem im having. can you look at the other post for me in forums php img loops?
Jan 17 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
7786
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
6
3434
by: John | last post by:
Hi. I am having a few header problems at the moment with a login page. I don't have my headers at the top of the page where I've learned I need to have them. However, I also know I'm supposed to have the session_start(); at the top of the page as well. So when you have two things that need to be the first which do you put first? And if I put one before the other will that cause problems? Below is a copy of the php from my page. It...
9
3661
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
4
1521
by: raghavendra | last post by:
hi, i have gone through this link http://msdn.microsoft.com/library/default.asp?url=/workshop/security/privacy/customimportxml/thirdparty.asp.. i want to know, how to use this below code in ASP.NET. <thirdParty noPolicyDefault="accept" noRuleDefault="accept" alwaysAllowSession="yes"/>only, because of the cookie was not residing physically on hard disk.Thankx ,Raghavendra tilve
4
15468
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site | Properties | Configuration | Options | Enable Session State Session timeout 20 (3) within Global.asax.vb file - Session_Start subroutine can use Session.Timeout=x minutes or (4) within any web page, i.e., <web page>.aspx can use...
7
7776
by: Doug | last post by:
An ASP.NET session cookie set on "www.mydomain.com" can not be accessed on "search.mydomain.com"; hence, a new session and cookie are being created on every sub-domain. This is occuring because ASP.NET always sets the Session cookie domain to the full domain (e.g. "www.mydomain.com") instead of the parent domain (e.g. "mydomain.com") The problem with this is when the visitor goes to a different sub-domain (e.g. "search.mydomain.com"),...
9
5314
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of copy paste (I hear this will improve in ASP.Net 2 via master pages). When I navigate from one page to the next the header and footer user controls lose their state because they are effectively different instances of the user control. Is there...
11
7919
by: Joseph Geretz | last post by:
I've been looking at two approaches for the maintenance of Session state for a Web Service application. One approach uses the old familiar Session object which I've used in the past for Web applications. As far as I can see, the Session approach is non-standard since Web Services are supposed to be agnostic with respect to their clients. It seems that cookies are outside the Web Service standard; therefore, such a Web Service application...
3
1352
by: sheldonlg | last post by:
In some code I inherited there is use of the TDC control to display table data. In trying to fix a problem, I put a couple of session variables into the module that is specified by the DataURL property of the TDC control. Call this module data.php. Call the page that I am on page.php. The two session variables are: 1 - $_SESSION = $totcost; where $totcost is what I actually want 2 - $_SESSION = $current_file . '<br>' . $_SESSION;
0
9489
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
10072
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...
1
9885
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
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
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
7286
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
5172
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...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.