Jump to content

Where to locate session cookie for general site and administrator sub-directory site


NotionCommotion

Recommended Posts

I have several "sites" located in my html directory, and each has a "general" access point and an "administrator" access point:

/var/www/html/site1/index.php
/var/www/html/site1/administrator/index.php
/var/www/html/site2/index.php
/var/www/html/site2/administrator/index.php
/var/www/html/site3/index.php
/var/www/html/site3/administrator/index.php

All sites are similar except that data will be specific to site1, site2, or site3, etc.

 

Users who log onto /var/www/html/siteX/index.php are totally unrelated to those who logon to /var/www/html/siteX/administrator/index.php, will have different logon credentials, are stored in different DB tables, and each should have their own session.  If a user logs off of either the general or administrator site, it should not effect the other site even if they were previously logged on to both on the same PC (and of course not effect other sites). When a user logs off, I would like to destroy their previous cookie and associated session.  Users for either will only use https.  I am using Apache to rewrite https://www.mysite.com/ to https://mysite.com/.  While I named the administrator site "administrator" above, the administrator user has the ability to change the directory name.

 

I am thinking I need to use session_set_cookie_params to specify where I wish the session cookie to be stored since /var/www/html/siteX/administrator/index.php is a sub-directory to /var/www/html/siteX/index.php, but am not really sure.  Sorry for the cryptic post, but I am not very well versed in this subject. How would you recommend setting up cookies/sessions for this scenario?  Thank you

Link to comment
Share on other sites

That is the default name for the cookie for containing the session id. 

 

Yes. You can use session_name to give your session cookie a unique name for each site.

Thanks ChOcu3r.  Note sure if it will be necessary, but good to know.

 

My bad.  I read different cookies for different instances of the app across folders.

 

Of course now I ask the question - won't multiple users have different sessions anyway?  Whats the concern about sessions?

Thanks ginerjm,

 

I don't think users have sessions, but clients have sessions.  If a user visits http://mysite.com/site1/index.php and http://mysite.com/site1/administrator/index.php, there will be two session cookies set, right?  What about http://site1.mysite.com/index.php and http://site1.mysite.com/administrator/index.php?  Two more? Then there is http://www.mysite.com/site1/index.php (however, I indicated that I will be rewriting, so maybe these are not an issue).  I was getting lost in the number of cookies, and wanted to centrally locate them under just http://mysite.com/site1.  But then, if the general user logs off of a given client, the administrator user on that same client is logged off.

 

Link to comment
Share on other sites

True dat.  So it sounds like you will have to assign a new session id when a user logs in which would then make that browser session separate from any other brower session that client is then running.  Not the session cookie name as I understand it - simply get a new session id.

Link to comment
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.