Jump to content

Unique Session variable enough? getting logged out and in on every project


lobfredd

Recommended Posts

Hello!

Everybody in my class have their own folder on a domain, so its like: www.thedomain.no/nameofstudent.

The problem we are facing is that when i log in on my  site i also get logged in on all the other students sites too...

(we are all using Dreamweaver CS5.5)

 

We all have a: Welcome, USERNAME, massage on our sites. However if i first log in on my site, then visit another students site i get the massage: Welcome, (and the username i logged in with on my site!)

 

another problem is when i try to access the shopping cart of student X's site (then i get redirected to the loging page on his site), If i then leave that tab open in chrome and open a new one, then i go to my login page in than new tab ON my site, then i log in on my site. Instead of getting redirected to MY index i get redirected to  student X's shopping cart...

 

I tried to rename the Session variable without luck. (default dreamweaver is $_Session['MM_Username'])

 

Any Suggestions?

 

Hope i made myself understandable

Thanks

Link to comment
Share on other sites

This seems like the issues caused by session over-use. Use sessions only to track state, not things like page redirects, or other information that could get changed by a user having the same site open in multiple tabs.

 

The easiest, and most secure solution IMO is a custom session handler. One that tracks which 'subdirectory' the session belongs to.

 

Problem here is that a cookie will be accessible to all paths above the one it was set it. A cookie set in the root, will be accessible from both root/folderA and root/folderB.

 

Subdomains could be another solution as well, unless a cookie is set to '.domain.com', it won't be accessible from subdomains.

Link to comment
Share on other sites

Aren't sessions and cookies on the domain, not the folder?

 

If you renamed the session variable, then there's no way that their code which is looking for MM_Username would accept your name which is NOT MM_Username.

Link to comment
Share on other sites

Aren't sessions and cookies on the domain, not the folder?

 

If you renamed the session variable, then there's no way that their code which is looking for MM_Username would accept your name which is NOT MM_Username.

 

I thought the same so i renamed mine, however the problem still exists..

Dreamweaver got a little mad when i changed it. with the slightest change to MM_Username i got this error: Untitled.png

 

and there were suddently 2 Log in User in the server behavior list..  :confused:

 

This is from my login.php

  //declare two session variables and assign them

    $_SESSION['fgnuser'] = $loginUsername;

    $_SESSION['fgnuserg'] = $loginStrGroup;      

 

and this is from my logout.php

<?php
// *** Logout the current user.
$logoutGoTo = "index.php";
if (!isset($_SESSION)) {
  session_start();
}
$_SESSION['fgnuser'] = NULL;
$_SESSION['fgnuserg'] = NULL;
unset($_SESSION['fgnuser']);
unset($_SESSION['fgnuserg']);
if ($logoutGoTo != "") {header("Location: $logoutGoTo");
exit;
}
?>

 

So the weird thing is when i click the logout button on one of my class mates sites i get logged out from mine too..

 

EDIT: kinda figured something out, could one of the students maybe destroy the whole cookie or something to logout?

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.