Re: PHP Sessions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Your assumption is correct.

When you create a session there are 2 ways it gets tracked. Via URLs or via the session Cookie. By default, it is stored in Cookies when it can.

So when you do session_name('TEST'), a cookie named TEST will be created and it would have the value of the session id.



On Thu, Jan 27, 2022 at 11:28 AM <paulf@xxxxxxxxxxxxxxxxx> wrote:
Folks:

I've been using session_start() and session_name('something') for years
without thinking much about it. But I've started to wonder if there's
an advantage to "naming" a session versus simply allowing PHP to assign
a session ID to it. This had dredged up other questions I haven't been
able to find the answers to.

I have some finance software with various forms, and a menu to navigate
to the different pages/forms. Assuming I run session_start() at the
beginning of each page, under what circumstances would PHP actually
create a new session with a new ID?

I know there's a time limit on sessions in PHP, but is it reset for
each access?

>From my experiments, if I'm connected to a single server, no matter
what software I run on that server, using a specific running browser,
I'll get the same session ID, according to session_id(). That is, if
I'm connect to localhost (for example), in Firefox, I can visit any PHP
software I've written on that server in any tab and get the same
session ID. A different user will get a different session ID on their
machine/browser.

>From what I can see, setting session name would only serve to give me a
different session for each piece of software I write. (Assuming I tell
each piece of software to set a different session name when it starts.)
Is that right?

Paul




--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux