Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sesssions and Cookies - PHP

Status
Not open for further replies.

MadneM

IS-IT--Management
Mar 2, 2005
5
GB
Hey, I'm developing a script using frames - no comments please....

and i basically need to be able to use sessions or cookies to store temporary data in, however due to the restraints on the session and cookie functions ie, cant initiate after output has already been sent, how can i possibly get either cookies or session variables to work? I know i could store my data in a database but then that produces lag and unnecesarily stored data, anybody found a way round this or can think of a different way to store this temporary data?

Thanks

MadneM
 
What are you trying to do? I've never run across a situation where I could not reorganize my code so that the cookie or session-variable settings couldn't appear before my output. This is especially true of sessions, where all you need do is add:

session_start();

as the first line of your script, then set sessions anywhere you need to in your code.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
well im using frames so once output has already been sent ie in the first frame, i cannot send it again in a later frame because output has already been sent.... the content in the first frame, so if i put in the session start() doodly it just comes up with a header already sent message

thanks
 
can't you use session_start() in the frameset document?
 
Each frame in a frameset is a separate communication between the web server and web client. What you do with headers in one frame's fetch does not affect another.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
no they do affect each other, at least on the setup i am running, however i'v used the ob_start() function to deal with the error. thanks anyway
 
No, they do not.

HTTP requires that the server response return a single, non-multipart-MIME content-stream. When the browser fetches a frameset page, the content of the individual frames cannot be sent through the same server connection as the frameset document. The browser, then, opens another network connection to the server to fetch the content. This means that each PHP script producing each frame's content is running separately from the others in a separate program space.

The way to verify this is to fetch the content of only one frame as a standalone web page. If you still get the error, the frames are not part of the problem. See section 1.4 of faq434-2999 for information about the "headers already sent" error.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top