Jump to content

[SOLVED] session help


ngreenwood6

Recommended Posts

Ok so my main page has a session. I am using the session id to query the database. Now when I post to a page I have start_session() at the top but when I echo the session_id() on the main page and on the page that was posted to they are 2 different values. Why is it changing the session_id()? Is there a way to make it keep the original value?

Link to comment
https://forums.phpfreaks.com/topic/181967-solved-session-help/
Share on other sites

The correct function is session_start() not start_session()!

The session will be maintained throughout the application and should not change its id unless it is destroyed or you are failing to restore it using the session_start() function. You should place this function in an include common to all files so you do not have to add the function to all scripts, just make sure the file is included i.e include('config.inc.php');

 

If you are using the session id to querythe db, are you implying that you have a custom session handler using database storage? If so, maybe your problem lies there.

Link to comment
https://forums.phpfreaks.com/topic/181967-solved-session-help/#findComment-959881
Share on other sites

yeah I am using session_start(); sorry it was a long day and I was a having some typing issues. I actually figured out the issue. A different place in code there was a session_name(); defined other than the original. So when I called session_start(); on a separate page it wasnt getting that session_name() and therefore getting a new id.

Link to comment
https://forums.phpfreaks.com/topic/181967-solved-session-help/#findComment-960566
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.