PDA

View Full Version : Sessions help :(



Fehm
08-02-2009, 08:51 PM
Hey :)

I'd like to say sorry to begin with, because im learning PHP, and all i keep doing is come back here for advice, so i'd be more than understanding if you lot didnt help me anymore!

My problem now is:

Warning: session_start() [function.session-start (http://clubpixels.co.uk/callum/function.session-start)]: Cannot send session cookie - headers already sent by (output started at /home/clubpixe/public_html/callum/index.php:10) in /home/clubpixe/public_html/callum/index.php on line 20

Warning: session_start() [function.session-start (http://clubpixels.co.uk/callum/function.session-start)]: Cannot send session cache limiter - headers already sent (output started at /home/clubpixe/public_html/callum/index.php:10) in /home/clubpixe/public_html/callum/index.php on line 20

that comes up on my log in form

Now the code it mentions is this:


<?php

session_start();
include("config.php");

if(isset($_SESSION['logged_in'])) {

}

And i just dont know what i've done wrong.... Knowing me it'll be a very silly mistake... and if its not too much to ask, If you do try and help can you tell me how you came to that conclusion so i can learn rather than copy and paste??

Thank yooo :)
Callum

Joe!
08-02-2009, 08:52 PM
You need to put session_start(); before anything else on the page, so you could just do <?php session_start(); ?> right at the top of the page, before any other code.

Fehm
08-02-2009, 08:59 PM
You need to put session_start(); before anything else on the page, so you could just do <?php session_start(); ?> right at the top of the page, before any other code.


Thanks alot, +rep!

Joe!
08-02-2009, 09:09 PM
Your welcome.

Fehm
08-02-2009, 09:14 PM
Thing is though..... Its on a page with Div's etc.... Does this mean that just;

<? session_start (); ?> goes before the Div or is it that enter phrase inc. the config.php and stuff???

Thanks again :)

Joe!
08-02-2009, 09:22 PM
It should go right at the top of page. before the <head></head> tags.

Fehm
08-02-2009, 09:28 PM
thanks :)

HabbDance
08-02-2009, 09:29 PM
It should go right at the top of page. before the <head></head> tags.
Before doctype?

Fehm
08-02-2009, 09:31 PM
Warning: session_start() [function.session-start (http://clubpixels.co.uk/callum/function.session-start)]: Cannot send session cookie - headers already sent by (output started at /home/clubpixe/public_html/callum/index.php:3) in /home/clubpixe/public_html/callum/index.php on line 3

Warning: session_start() [function.session-start (http://clubpixels.co.uk/callum/function.session-start)]: Cannot send session cache limiter - headers already sent (output started at /home/clubpixe/public_html/callum/index.php:3) in /home/clubpixe/public_html/callum/index.php on line 3


Now i get that like above my layout ^^

Fehm
08-02-2009, 09:32 PM
Sorted!
Goes above doctype

thanks to everyone for their help :) I'll plus rep when i can!

HabbDance
08-02-2009, 09:39 PM
Sorted!
Goes above doctype

thanks to everyone for their help :) I'll plus rep when i can!
Your welcome :)

Joe!
08-02-2009, 09:46 PM
I always forget about anything above the head tags, its bad i know ;p

Fehm
08-02-2009, 10:22 PM
I always forget about anything above the head tags, its bad i know ;p


Lol well now you know :)

In my php, after youve logged in it goes to index.php and on that page i have the sessio_[username] thing from the other page, and it doesnt show up :(

Anyway i can help that? I might just play around with it?
Thanks again :d

Joe!
08-02-2009, 10:25 PM
You have session_start on every page yes? I assume you are setting the sessions correctly as well :]
Might be able to be more helpful if you post your code.

Ryzie
09-02-2009, 07:22 AM
Make sure you only have one session_start too.

Fehm
09-02-2009, 04:43 PM
Make sure you only have one session_start too.

yh i know that

And session_start is on every page... And (Im still learning, i feel like a noob askins) can you give me some hinters as to how i should of set my sessions, as far as i know i have... lol

Thanks again :)

Fehm
09-02-2009, 04:45 PM
Sorry for double post :)

And i have now fixed the problem i had,

:) thank you!

Want to hide these adverts? Register an account for free!