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 01-06-2008, 03:00 PM Login
BlackWater's Avatar
Experienced Talker

Posts: 31
Trades: 0
Hey,

I'm looking for how to make a script that when a user logs into a page, it displays content that is embedded in the page that normally could not be seen unless logged in. However, when the user logs in no one else should be able to see the embedded content or be able to login with that user's password and username.

Cookies don't work very well

Any help, thanks!
__________________
Code:
if( $hungry ) { eat(); } 
    else { sleep(); }
BlackWater is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-06-2008, 03:05 PM Re: Login
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
PHP if's and includes.

PHP Code:
if(/* User logged in */){
inclde "logged_in.php";
} else { 
// not logged in
inclde "not_logged_in.php";

__________________
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 01-06-2008, 03:15 PM Re: Login
BlackWater's Avatar
Experienced Talker

Posts: 31
Trades: 0
How do I get that to work with a session?
__________________
Code:
if( $hungry ) { eat(); } 
    else { sleep(); }

Last edited by BlackWater; 01-06-2008 at 05:04 PM..
BlackWater is offline
Reply With Quote
View Public Profile
 
Old 01-06-2008, 07:40 PM Re: Login
mihai074's Avatar
Experienced Talker

Posts: 36
Trades: 0
well, i use a session variable...like $_SESSION['logged'] , also with an 'if' ... like so:
PHP Code:
if ($_SESSION['logged'] == TRUE
 {
 
         
//content for a logged user

  

     else {

      
//content for a unlogged user
  
  

p.s. always place a session_start() at the beginning of your pages.
__________________
Fun -
Please login or register to view this content. Registration is FREE

Last edited by mihai074; 01-06-2008 at 07:44 PM..
mihai074 is offline
Reply With Quote
View Public Profile
 
Old 01-06-2008, 08:12 PM Re: Login
BlackWater's Avatar
Experienced Talker

Posts: 31
Trades: 0
I would do it that way, but that way also happens to iframe resistant. Unless I've made an error in how I set the $_SESSION[''] up.

Website A = Editor
Website B = Being Edited

User Logs into Website A. Upon logging in Website B is brought up in an iframe. From there, I'm trying to get Website B to recognize that its in edit mode and bring up the embedded code that allows the edit. I can get it to work however I can't isolate it simply for the user that is logged in.
__________________
Code:
if( $hungry ) { eat(); } 
    else { sleep(); }

Last edited by BlackWater; 01-06-2008 at 08:22 PM..
BlackWater is offline
Reply With Quote
View Public Profile
 
Old 01-06-2008, 11:53 PM Re: Login
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Sessions and cookies are not supported across multiple domains and websites. The only I can think of solving this issue is to use a "behind-the-scenes" method to request the logged in status of the previous site.

I-Frame tag from Website A:
PHP Code:
<iframe name="name" src="http://www.website-b.com/index.php?<?php echo 'session_name=' session_name() . '&' session_name() . '=' session_id(); ?>"></iframe>

The index.php page in the I-Frame from Website B:
PHP Code:
<?php
  
  $user_logged_in 
false;
  if (isset(
$_GET['session_name']) AND isset($_GET[$_GET['session_name']]))
  {
    
$handle = @fopen('http://www.website-a.com/check_login.php?' $_GET['session_name'] . '=' $_GET[$_GET['session_name']], 'r');
    if (
$handle && (int)@fread($handle1024)) $user_logged_in true;
  }
  
?>

The check_login.php page located in Website A:
PHP Code:
<?php
  
  session_start
();
  
  echo (
$_SESSION['logged_in']) ? '1' '0';
  
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Login
 

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