Forum Moderators: coopster

Message Too Old, No Replies

Propagating Unique Session Cookie Names

         

justgowithit

10:37 pm on Jan 28, 2007 (gmt 0)

10+ Year Member



Does anyone know of/have any suggestions about how to generate and propagate a random unique name for session cookies?

justageek

10:49 pm on Jan 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sessions will be unique already for the file names it keeps but if you want unique names for other session variables for some reason and if the names don't have to have characters then just use rand().

JAG

justgowithit

10:55 pm on Jan 28, 2007 (gmt 0)

10+ Year Member



Sessions will be unique already for the file names it keeps

The session ID is unique, but the cookie name referring to the session data is not - wherein lies the problem.

I am aware of how to generate unique IDs, the problem is propagating the information from page to page. When talking about session data it is not that easy. Even using a buffer I can't seem to get the cookie name to carry.

I've never had this problem before because I assign a unique cookie name to each individual app. In this case I don't have that option.

justageek

11:04 pm on Jan 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not quite following what you want to do exactly. You mean you don't want to use the default phpsessid cookie name? If that's it then you can use session_name(). If not can you explain what you want to do exactly?

JAG

justgowithit

1:41 am on Jan 29, 2007 (gmt 0)

10+ Year Member



I don't think it's possible to do what I'm hoping. I cannot use the default session cookie name because I need each session (not just each user) to have a unique session cookie name.

I've gone through a few different trials using session_name(), but it is not possible. To do so requires that the unique name be generated and then session_name() to be called prior to session_start on each subsequent page. I have not been able to successfully pass the unique cookie name. If session_name() is not called specifying the newly generated name the session will resort back to the default and the confusion starts again.

I've tried using buffers and cookies but both fail because I can't send/get info from the client prior to session_start.