SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: session problem

  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    session problem

    I am using xampp and a cart class that use sessions (it initialize as a session variable).
    My problem is I use that cart class for many sites so when I add an item at a site that item will be at the cart of other sites (they are in subfolders of 'local' server-local/domain1 , local/domain2)
    I thing it happens because all these subfolders have the same session
    via local/.
    How each subfolder can have their own session?

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    may be when you switch the folder then destroy the older one and create the new one with that folder.

  3. #3
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We use the 'local' (xampp) server as testing server and we 'put' the sites as subfolders at this server. (local/domain1, local/domain2 etc)
    So it is not a good practice to delete any subfolder.
    Is there any method to start a session with a unique id for example?

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Not entirely sure, but wouldn't you have to create virtual-hosts for those? Then your cookies would be domain specific and not available globally under localhost.

    Just a thought.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just used the
    session_name("mysubfolder");
    for 2 subfolder and it seems to seperate the sessions.
    The previous idea maybe works but me personally , I have not access to do this.

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Edit: Ah no matter, I got a little confused, headed on over to the manual to educate myself.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    using a different session_name() is a decent way to do it. Even better though is SilverBulletUK's suggestion to set up different virtual hosts.

    Another way is to session_set_cookie_params() and set the cookie path to the directory in the url.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •