Page 1 of 1

sessions

Posted: Tue Apr 20, 2004 5:52 am
by mike08
im a bit confused with sessions though

should i put start_session(); on every page including my index.php page which is my homepage.

i have these files before a user logs in

forgot password
register
home

when a user logs in they have access to

poll
change password
guestbook

do i have to put include session_start; on every page its just ive included it on guestbook and it comes up with this error

A session had already been started - ignoring session_start() and the same message on the change password page.

im not using sessions on the guest book page or the change password page is that why? Its just i though you had to include start_session() on every page you view once logged in? is this correct or am i doing something wrong

please can someone advise me what to do and which pages should include sessions?

Posted: Tue Apr 20, 2004 5:57 am
by JayBird
You only need to use session_start on pages when you need access to session variable.

for example, you could start a session, then go to another page that doesn't need the session variable, then on another page, restart the session and have access to the session variable from the first page.

As for the error message, are you including any files that you may have put session_start in?

Mark

Posted: Tue Apr 20, 2004 6:11 am
by mike08
Thanks i think i understand now

it seems to work fine now

ive taken out the start_session in guestbook and change password as im not using session variables on those pages.

cheers.

quick question.

on my site a registers then gets sent to the homepage where then can leave comments in the guest book. i obviously don't want to have them fill in another username and and email address as will already have that.

so in the form would i just call up their information using session variables, could you give me a little examle as to how to do that please?

Posted: Tue Apr 20, 2004 6:18 am
by JayBird
read this tutorial.

Not exactly what you need, but if you read it, you will understand more and be able to figure it out for yourself - viewtopic.php?t=6521

Mark

Posted: Tue Apr 20, 2004 6:35 am
by magicrobotmonkey
Didn't I already tell you how to do that or was that someone else? well it was a recent thread anyways - this forum has a serch function!