trouble using another website cookie in EE tmplate
Posted: 08 March 2005 11:37 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  208
Joined  06-07-2004

If need be, I can explain this further, but would anyone know why I cannot use a login script to another cookie/database in an EE template. I’ve got PHP enabled, and I’ve tried it on both settings—Input vs Output, but EE just seems to ignore the script. Here’s what I place at the top of my template:

if (!isset($_COOKIE[‘webinsider’]))
{
  Header(“Location: http://www.XYZ.com/us/registration/registration.php”);
}
else
{
$Email = $HTTP_COOKIE_VARS[‘webinsider’];
// Establish connection
echo $varEmail;
include(”../../Connections/webdb.php”);

// Verify Login is correct
mysql_select_db($database_webdb, $webdb);
$query_rsLogin = “SELECT * FROM users WHERE users.varEmail = ‘$Email’”;
$rsLogin = mysql_query($query_rsLogin, $webdb) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);


// If no Login, delete cookie and redirect to Access Denied message
if($totalRows_rsLogin==0){
setCookie(“webinsider”,”“,time()-86400,”/”);
setcookie (“webinsider”, “”, time() - 3600);
Header(“Location: http://www.XYZ.com/us/registration/accessdenied.php”);
mysql_free_result($rsLogin);
} else {
mysql_free_result($rsLogin);
}
}

Profile
 
 
Posted: 08 March 2005 01:45 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  208
Joined  06-07-2004

Interesting footnote: With Firefox, EE will display the template as if script isn’t even there. IE, however, produces a number of errors:

Notice: Undefined variable: HTTP_COOKIE_VARS in /home/www.XYZ.com/public_html/ee/system/core/core.functions.php(541) : eval()‘d code on line 8

Notice: Undefined variable: varEmail in /home/www.XYZ.com/public_html/ee/system/core/core.functions.php(541) : eval()‘d code on line 10

Notice: Undefined variable: database_webdb in /home/www.XYZ.com/public_html/ee/system/core/core.functions.php(541) : eval()‘d code on line 14

Notice: Undefined variable: webdb in /home/www.XYZ.com/public_html/ee/system/core/core.functions.php(541) : eval()‘d code on line 14

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/www.XYZ.com/public_html/ee/system/core/core.functions.php(541) : eval()‘d code on line 14

Notice: Undefined variable: webdb in /home/www.XYZ.com/public_html/ee/system/core/core.functions.php(541) : eval()‘d code on line 16

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www.XYZ.com/public_html/ee/system/core/core.functions.php(541) : eval()‘d code on line 16

Profile
 
 
Posted: 08 March 2005 04:17 PM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

The difference in error displays might occur if you’re logged in with IE and not with Firefox.

The first two things I would suggest:

1. Switch “$HTTP_COOKIE_VARS” to “$_COOKIE”

2. On your include(”../../Connections/webdb.php”);, use the full server path to the file and not a relative path.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 10 March 2005 10:35 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  208
Joined  06-07-2004

Thanks for the tip ... Maybe be getting closer, but I’m still working on this. Here’s the latest error:

MySQL ERROR:

Error Number: 1146

Description: Table ‘webdb.exp_global_variables’ doesn’t exist

Query: SELECT variable_name, variable_data FROM exp_global_variables WHERE user_blog_id = ‘0’

So it’s actually appending EE query statements (actually, the EE database) with the name of my other database.

If you have any other suggestions,

Profile
 
 
Posted: 10 March 2005 02:03 PM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

Are you trying to access a completely separate database?  What about moving the tables from whatever other script you’re using into the EE database?

It looks like you might be connecting to a separate database and then never closing the connection, so when EE goes to query something else it’s still using the connection you left open, which is to the wrong database (and thus wrong tables).

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64978 Total Logged-in Users: 30
Total Topics: 82017 Total Anonymous Users: 16
Total Replies: 440817 Total Guests: 174
Total Posts: 522834    
Members ( View Memberlist )