Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Archive > Archives of Old Posts > Web Design and Development (archive)

 
 
Thread Tools Search this Thread Display Modes
Old Jan 1, 2004, 09:53 AM   #1
mrjamin
macrumors 65816
 
mrjamin's Avatar
 
Join Date: Feb 2003
Location: Strongbadia
php sessions and IE4/5

Yo,

i've been using sessions in PHP for a little while now, and recently tried to log into a site i made that used sessions to maintain logins etc, and it was doing weird stuff in IE4. It seemed that it created the session, but the session wasn't carried accross pages. Any known issues? Here's the code i used:

PHP Code:
session_start();
require(
'dbconnect.inc.php');
require(
'functions.inc.php');
if(isset(
$_POST['Submit'])){
    
$sql "SELECT * FROM `users` WHERE `username` = '$_POST[username]' AND `password` = '".crypt($_POST['password'],"salt")."' LIMIT 1";
    
$result mysql_query($sql);
    if(
mysql_num_rows($result) == 1){
        
$_SESSION['username'] = $_POST['username'];
        
$_SESSION['login'] = time();
        
$_SESSION['admin'] = true;
        if(
mysql_result($result,0,superuser) == 1){
            
$_SESSION['superuser'] = true;
            
$append yes;
        }
        
header("Location: admin/index.php?$append");
        
$sql "UPDATE `users` SET `lastlogin` = UNIX_TIMESTAMP() WHERE `username` = '$_POST[username]' AND `password` = '".crypt($_POST[password],"salt")."'";
        
mysql_query($sql);
    } else {
        
$badlogin true;
    }
} elseif(isset(
$_SESSION['username']) && $_SESSION['login'] < strtotime("-10 minute",time())){
    
$expired true;
    
session_destroy();

Any idea why IE4 didn't like this? Once logged in, it successfully redirected you to the protected area, but then the headers in the protected area pages redirected the user back to an "access denied" page, as though the session wasn't carried on. Any tips would be appreciated.

Here's the sessions code of each protected page:

PHP Code:
session_start();
if(!isset(
$_SESSION['username']) || !isset($_SESSION['login']) || !isset($_SESSION['admin'])){
    
header("Location: ../denied.php");
} else {
    if(
$_SESSION['login'] < strtotime("-10 minute",time())){
        
header("Location: ../adminlogin.php");
    } else {
        
$_SESSION['login'] = time();
    }

__________________
FCKGWRHQQ2YXRKT8TG6W2B7Q8

Last edited by mrjamin; Jan 1, 2004 at 10:09 AM.
mrjamin is offline   0

 
MacRumors Forums > Archive > Archives of Old Posts > Web Design and Development (archive)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
With all the 4S leaks and no 5 leaks, could we see just one phone? CAWjr iPhone 16 Oct 3, 2011 11:55 AM
Shenzhen Saiga Electronic Market Know Offs and iPhone 5 News ChinaAzzi iPhone Accessories 5 Jan 27, 2011 12:06 PM
Problem with PHP Session Variables Littleodie914 Web Design and Development 4 Oct 4, 2007 01:02 PM
PHP Session hell... bigandy Web Design and Development 14 Nov 5, 2006 04:56 AM
multiple php + sessions superbovine Mac Programming 3 Feb 27, 2006 09:58 PM


All times are GMT -5. The time now is 02:08 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC