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

Reply
Old 03-05-2009, 04:34 PM Sessions & Safari
Novice Talker

Posts: 7
Trades: 0
I cannot figure out why my session data is not available:

Here is the code for the login:

PHP Code:
<?php
session_start
();
include 
'mysqlconnectionUSERLEVEL2.php';
//check for required fields from the form
if ((empty($_POST["username"])) || (empty($_POST["password"]))) 
{  
 
session_destroy();
    
header("Location: http://www.foobar.net/login/login.html");
}
//print "Username & password set";
// print "<p> SET $username</p>";
//create and issue the query
$query "SELECT username, pass, user_level, first_name, last_name FROM users WHERE username = '".$_POST["username"]."'
 AND pass = SHA1('"
.$_POST["password"]."')"#PASSWORD('".$_POST["password"]."')";
$result mysqli_query($mysqli$query) or die(mysqli_error($mysqli));
//get the number of rows in the result set; should be 1 if a match
if (mysqli_num_rows($result) == 1
{  
     while (
$info mysqli_fetch_array($result)) 
 {
 
$f_name stripslashes($info['username']);
    
$first_name stripslashes($info['first_name']);
 
$last_name stripslashes($info['last_name']);
 
$user_level stripslashes($info['user_level']);
 } 
  if (
$user_level == "99")
 {
   
$_SESSION['first_name'] = $first_name;
   
$_SESSION['last_name'] = $last_name;
   
$_SESSION['user_level'] = $user_level;
  
// If headers were already sent for some reason, 
  // the upcoming call to header() will not work...
  //print $_SESSION['first_name'];
    
header("Location: http://www.foobar.net/sis/index.php"); 
  
//ob_end_flush();
   
}
}
/*
//destroy the session 
 session_destroy();
  //redirect back to login form if not authorized
    header("Location: http://www.foobar.net/login/login.html");
 exit;*/
 
session_write_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
</head>
<body>
</body>
</html>
here is the INDEX.php

Note login.php and index.php are in different folders
/mainfolder/login/login.php
/mainfolder/sis/index.php

here is the index.php

PHP Code:
<?php
session_start
();
print 
"NAME";
print 
$_SESSION['first_name'];
if(isset(
$_SESSION['last_name'])) 
{
  if (
$_SESSION['user_level'] = "2")
   include 
'mysqlconnectionUSERLEVEL2.php'// include the database connection for user level 
  
if ($_SESSION['user_level'] = "99")
    include 
'mysqlconnectionUSERLEVEL99.php'// include the database connection for user level 2
 
print "authorised";
}
else 
{
 print 
"UNAUTHORISED";
 
session_destroy();
    
header("Location: http://www.ark.net/");
  exit();
}
print 
"INDEX";
?>
The SESSION array is not available in the INDEX.php.. It is blank.
But works fine in Internet explorer

I verified that SESSION is set correctly right before the header call to index.php in Safari, but it is not accessible in index.php.

What am i doing wrong???
bcpaul is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-05-2009, 04:55 PM Re: Sessions & Safari
Novice Talker

Posts: 7
Trades: 0
oh and I have emptied the cache and reset the browser to no avail.

I will try to move the index to the same folder as login
bcpaul is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 05:00 PM Re: Sessions & Safari
Novice Talker

Posts: 7
Trades: 0
Okay moving the index.php to a subfolder of login.php did not do anything.
Cookies are enabled in all browsers


Still working fine in Interenet Explorer.
Does not work in Google Chrome either as well as Safari.

Must be something simple I am missing here
bcpaul is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 05:03 PM Re: Sessions & Safari
Experienced Talker

Posts: 33
Trades: 0
i have had the problem that
PHP Code:
session_start(); 

needs to be on the top line.

PHP Code:
<phpsession_start(); 
might work give it a shot.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
rambo3 is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 05:10 PM Re: Sessions & Safari
Novice Talker

Posts: 7
Trades: 0
Does not help...argggg
bcpaul is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 05:22 PM Re: Sessions & Safari
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
session_destroy(); could be running and erasing all data.

I suggest you clear the session files server side, they could be linking to you without a cookie (IP based sessions)
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 03-05-2009, 06:47 PM Re: Sessions & Safari
Novice Talker

Posts: 7
Trades: 0
deleted the sessions in /tmp

when I run the two php files it creates 2 sessions in /tmp


one is empty and one has the following:

first_name|s:4:"JOHN";last_name|s:5:"foobar";user_ level|N;

still no joy
bcpaul is offline
Reply With Quote
View Public Profile
 
Old 03-05-2009, 06:49 PM Re: Sessions & Safari
Novice Talker

Posts: 7
Trades: 0
i even changed the login.php to

PHP Code:
<?php session_start();
$_SESSION['first_name'] = "JOHN";
$_SESSION['last_name'] = "FLAHR";
$_SESSION['user_level'] = $user_level;
header("Location: http://www.foo.net/login/admin/index.php"); 
?>
and index.php to

PHP Code:
<?php
session_start
();
print 
"NAME";
print 
$_SESSION['first_name'];
if(isset(
$_SESSION['last_name'])) //if ($_COOKIE["auth"] == "1")
{
 print 
"authorised";
}
else 
{
 print 
"UNAUTHORISED";
}
print 
"INDEX";
phpinfo();
?>
still works only in ie7 nothing else
bcpaul is offline
Reply With Quote
View Public Profile
 
Old 03-06-2009, 04:07 PM Re: Sessions & Safari
Novice Talker

Posts: 7
Trades: 0
Apparently I used header http://foobar.net/login/login.php rather then http://www.foobar.net/login/login.php

when it comes to sessions http:// != http://www

Fixed...

Thanks for the help
bcpaul is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Sessions & Safari
 

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.62585 seconds with 12 queries