top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Question about session_id() and session_start()

0 votes

I find the Note in PHP document.

"Note: When using session cookies, specifying an id for session_id() will always send a new cookie when session_start() is called, regardless if the current session id is identical to the one being set."

I feel puzzled about this feature. Even if the current session id is identical to the one one being set, session_start will send a new cookie. I want to know why session_start behave in this way.

posted May 20, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

0 votes

You will find the answer in the PHP source code. If you don't want this to happen, check if the current session id matches with the value you want to set it to, and don't set if they match.

answer May 20, 2013 by anonymous
There are well over half a million lines of source code in PHP. It seems a little unhelpful to tell someone to go and read half a million lines of C when you could just tell them the answer?
0 votes

I guess it would be to help prevent session hijacks like explained here

answer May 20, 2013 by anonymous
Similar Questions
+1 vote

Getting the following two error -
Warning:session_start() : cannot send session cookie - headers already sent by(output started at.......)
Warning:session_start() : cannot send session cache limiter - headers already sent by(output started at.......)

+3 votes

1) Implement both algorithms
2) Test both on three cases of data:
a) sorted in increase order,
b) sorted in decrease order,
c) randomly
3) Use data of different sizes: 10000, 100000, 1000000.

+1 vote

I want to use Git in a project but only some developers can Access in some folders (not all folders of the Project). Can Git limits the access to folders to users? How?

An example:
Project p_example
Users: A, B and C

Only B and C can access into scripts, src and docs folders but A only can access into scripts folder.

0 votes

In android-O, there is "app" folder in vendor partition.(/vendor/app)If app is in that folder and is ran, is that a vendor process?

+1 vote

Our team lead and I recently discussed the pros and cons of breaking up a long source file into multiple source files. I tend to prefer one class per file, because I find the individual files easier to read and easier to find (with ctrl-p in Sublime). On the other hand, our team lead doesnt have issues with long source files. He argues that they are quite common in open-source projects. As an example, he pointed to the ActionDispatch::Routing::Mapper class in Rails as a case of a long file with multiple inline classes.

I am curious to learn the intent behind keeping all the contents of Mapper class within a single file. What were the advantages of taking this approach?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.