K, i am use to using Sessions in ASP and I am having some probelms with the Sessions in PHP. WHat i want to do is use a session to check if a person if loged in or not on all of the pages that you need to be loged in for.

When i use session_start() i get this error

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:\Web Stuff\PHP\2Computergeeks\editusers.php:1) in D:\Web Stuff\PHP\2Computergeeks\editusers.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\Web Stuff\PHP\2Computergeeks\editusers.php:1) in D:\Web Stuff\PHP\2Computergeeks\editusers.php on line 3

Notice: Undefined variable: _session in D:\Web Stuff\PHP\2Computergeeks\editusers.php on line 4

This is the code that i am using when i get the error

<?php
session_start();
if (!$_session['login'] == "true"){

If i remove the session_start then i get the Undefined variable: _session error still. I just need to know the basics of using sessions. I am having a hard time finding any info on how to use sessions in PHP. THanks for any help.

PS. do i have to do a Session_start on every page that i want to use Sessions on? and do i have to register sessions before i can use them? I get error when i do session start and when i do a session register. Thanks

PS2. I am using the newest version of PHP.

    Make sure there arent any errors in your code first. Im not too certain (Havent used sessions in a long time) but i think that sessions as well as cookies cannot be after any output.

      the rest of the site is working fine. I am just having a hard time getting the sessions to work on all of my pages. Do i have to tell them how to be saved or send to the other pages? I am really lost when it comes to PHP sessions.

        Sessions and Cookies are considered headers and can only be sent before ANY output is genereated. A blank line outside the '<?php' tag is considered output. Make sure, this is the first thing you send to the browser. You can use the Object Buffer functions to help you.

          I LOVE YOU.

          Thanks. I had a

          <SCRIPT LANGUAGE="JavaScript1.2" type="text/javascript"></SCRIPT>
          

          on the top of the page. I think i know what i need to do now. THANKS

            Write a Reply...