tags:

views:

156

answers:

2

I was used to naming my session variables the "normal" way, kinda like when I want to keep track of user details, I name them:

  • $_SESSION['username']
  • $_SESSION['email']
  • $_SESSION['id']

I am worried that they may be in conflict with other session data when I am browsing sites in the same browser, or will there not be any conflict at all(once I tried to simultaneously run two of my projects with the same session variables, residing in the same server, and obviously, things got real messy).

+2  A: 

Consider setting them in a subarray related to your application:

$_SESSION['myapp']['username']
$_SESSION['myapp']['id']

That should significantly help avoid conflicts.

EDIT: I misread your question, Luca Matteis has your answer. My solution above would be to avoid your multiple apps on the same domain session conflict.

Cryo
I did the same mistake, but that's not what he wanted to know...
Franz
You are right, I updated my answer. Thanks.
Cryo
+7  A: 

All of the session data is stored on the server. All the browser has is a cookie that references the session on the server. There can't be naming conflicts for this reason, and also because Cookies naming scope is domain based.

Luca Matteis
I just wanted to write a mad reply, but then realized that you got it right. That's what he wanted to know. +1
Franz