Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
PHP Session Crossover? How Did This Happen?
Old 02-27-2010, 10:34 PM PHP Session Crossover? How Did This Happen?
MattGoucher's Avatar
Skilled Talker

Posts: 64
Name: Matt
Location: California
Trades: 0
Hey Webmasters,

I'm struggling with a rather large and powerful issue. Let me give you a basic run over of the program:

As you can see, this page add's a logout link based on what your session's username is.
PHP Code:
<?php
    session_start
();
    
$Username $_SESSION['username'];
    echo 
"<a href='?logout=True'>Logout($Username)</a>";
?>
Heres where the problem starts: The session (username) is logged when the user logs in. Something like this:
PHP Code:
<?php
    session_start
();
    
$_SESSOION['username'] = $_POST['Post_Username'];
    
header('location: someotherpage.php');
?>
So, While testing my page out, I accessed my page on my computer, logged and saw that the log out link looked like this:

Code:
Logout (Matt)
Which is exactly what I wanted. However when I logged in on my phone or any other computer as "bob", I would then refresh my computer to see that the link had been changed from (Matt) to (Bob).

The username session "Matt" and "Bob" had been crossed over!

As you can see this can cause a major problem, when the session has to do with whether or not the person has admin access.

What is happening? Why is my session getting swapped with another user logged on at the same time?

Is this a php.ini problem? Did I miss some code when setting the sessions?

Last edited by MattGoucher; 02-27-2010 at 11:04 PM..
MattGoucher is offline
View Public Profile Visit MattGoucher's homepage!
 
 
Register now for full access!
Old 02-28-2010, 07:25 AM Re: PHP Session Crossover? How Did This Happen?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.mobile-tech-today.com/sto...d=103007DUU1DW
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 02-28-2010, 04:06 PM Re: PHP Session Crossover? How Did This Happen?
MattGoucher's Avatar
Skilled Talker

Posts: 64
Name: Matt
Location: California
Trades: 0
Quote:
Originally Posted by chrishirst View Post
That was a very interesting article. I actually did solve the problem. I completely rewrote my scripts altogether. Luckily I'm pretty anal about testing for glitches, and I caught this one before my user's database built itself up.

Consider This Thread Closed, Thanks
MattGoucher is offline
View Public Profile Visit MattGoucher's homepage!
 
Closed Thread     « Reply to PHP Session Crossover? How Did This Happen?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22393 seconds with 12 queries