Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.