SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Login and session variables

    Hi,

    I am slowly teaching myself the basics of PHP and have a quick question that I am sure will be obvious but would appreciate the feedback.
    I am creating a test photo gallery application where a user has to log in to upload images.
    I am using sessions to check whether the user is logged in or not. My question is:

    If I have this code:
    PHP Code:
    if(!isset($_SESSION['userid'])){
        
    // session not logged
    }else{
        
    // session logged

    What happens if I have 2 different applications open in my browser and both use $_SESSION['userid'] to check login status?
    If I am logged in to 1 of the application won't that mean that it would register me as logged in in the other application.

    Please excuse my ignorance.

    Thanks

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,198
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Sessions are based on whatever page your visiting so for example if i visited both www.websitea.com and www.websiteb.com and they both used a session called userid they wouldn't conflict as the session only gets set for that specific URL.

    Hope that clears it up.

  3. #3
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brilliant - thanks

    If I was testing 2 applications in sub folders of the same domain name:

    www.website.com/applicationA
    www.website.com/applicationB

    Am I correct in thinking that this would cause a conflict?

    Cheers

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,198
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No, as long as the session is set within a different URL they won't conflict.


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
  •