Page 1 of 1

Help with sessions

Posted: Sun Jul 10, 2005 4:49 am
by raghavan20
1. Does php session change from page to page
In asp, the sessionid doesnot change across pages until logged off or the browser is closed, wot about php?

2. Do i have to use session_start() at every page? why do I have to do this?

3. If I use session_start() to inititate a session then isnot possible to access session id using session_id();?

4. I am developing a shopping cart, if a session id keeps changing then how can I store information about the cart in the db and I prefer storing cart information in db.

Re: Help with sessions

Posted: Sun Jul 10, 2005 9:10 am
by Dale
raghavan20 wrote:1. Does php session change from page to page
In asp, the sessionid doesnot change across pages until logged off or the browser is closed, <span style='color:blue' title='ignorance is bliss'>what</span> about php?

2. Do i have to use session_start() at every page? why do I have to do this?

3. If I use session_start() to inititate a session then isnot possible to access session id using session_id();?

4. I am developing a shopping cart, if a session id keeps changing then how can I store information about the cart in the db and I prefer storing cart information in db.
1. Nope, they stay the same, like ASP, until the browser gets closed.

2. Any page you want the session information to be used on will always require session_start() at the top.

3. erm... someone else will have to answer that.

4. The session ID will stay the same until the user closes the browser.

Posted: Sun Jul 10, 2005 9:32 am
by raghavan20
thanks for your reply mate.

but I dont understand why they wanted to use session_start() everytime when i wanted to access the sessionid using session_id()

Posted: Sun Jul 10, 2005 6:27 pm
by Dale
raghavan20 wrote:thanks for your reply mate.

but I dont understand why they wanted to use session_start() everytime when i wanted to access the sessionid using session_id()
Well you have to obviously tell the page that you want the sessional information to be started. So adding session_start() at the top of everypage seems pretty fine IMO.