PDA

View Full Version : Php Login


mironjohan
11-14-2006, 11:54 PM
How do i create a login to my website. I tried to set $_SESSION['login']='yes';
But when i run session_start()

i get:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/ebookcho/public_html/test/login.php:13) in /home/ebookcho/public_html/test/login.php on line 17

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ebookcho/public_html/test/login.php:13) in /home/ebookcho/public_html/test/login.php on line 17


The session variable 'login' is lost when tried to be accessed from a different page. Can some one please help me solve this.

:confused:

Thank You.

Seb
11-15-2006, 12:30 AM
Session_start() must be called before any output of code. Also try to look for whitespaces in your code before starting the session and remove them.

For example, session_start() must be called before <html> and all those HTML tags.

mironjohan
11-15-2006, 01:10 AM
Thank you :) Seb it worked perfectly fine. Since you are so good at this can i asked if my method is the best for logins???

Seb
11-15-2006, 07:43 AM
Best & best, depends on what type of login system you want.

If you need a secure system where users can create their own accounts you should use a database to store the info in and use encryption. This way it's also easier to maintain and add new features/settings.