PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I am having trouble with sessions.
Sessions work fine on one page, but when I navigate to another page they don't appear to be set. I'm sure there's something simple i'm doing wrong but I've been trawling around for some time now and got nowhere.
The session files do appear correctly in C:\php\sessiondata each time the page is refreshed.
Any help would be great!
Here's the code simplified -
page 1...
works fine
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
session_start() does not create a new session but starts php's session mechanism. You have to call it once each time php is called (~ for each http request)
when you press the link and reload the page session_name and session_id shouldn't change but a new line should be appended to session: each time. Does this work?
when you press the link and reload the page session_name and session_id shouldn't change but a new line should be appended to session: each time. Does this work?
thanks for putting that together.
In fact the session ID does change each time I refresh the page. nice eh?
timbrown wrote:In fact the session ID does change each time I refresh the page. nice eh?
No. New session id means new session, new set of data.
Does the output behind cookies: change as well? If yes your browser is probably rejecting all cookies and php is unable to store the session id client-side.
timbrown wrote:In fact the session ID does change each time I refresh the page. nice eh?
That would suggest your browser is not accepting the session cookie and your server is set to not use the URL as a fall back. session.use_trans_id among others will affect the behavior. You can use phpinfo() to see what options you have currently set.
timbrown wrote:In fact the session ID does change each time I refresh the page. nice eh?
No. New session id means new session, new set of data.
Does the output behind cookies: change as well? If yes your browser is probably rejecting all cookies and php is unable to store the session id client-side.
Yes the time does change in the cookies area. I will check browser settings again and come back.