Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 04-09-2003, 08:14 AM   #1 (permalink)
prendo
Registered User
 
prendo's Avatar
 
Join Date: Jun 2002
Location: Leeds
Posts: 11
prendo is on a distinguished road
How to check if a member is logged in?

Hi, I've created a member login section to my site and everything works fine except I can't figure out how to check if a user is logged in every time they visit a members only page.

I tried creating an include file called session_checker.php which defines a function called, you guessed it, session_checker.

Here's the code:

<?php //this function checks if user is logged in on a particular page
function session_checker(){
if(!session_is_registered('first_name')){
include 'login_form.html';
exit();
}
}
?>

Then on my members only page I started a session at the top and also tried to call the session_checker function via the include but this doesn't work for some reason. Here's the code:

<?php
session_start();
include 'session_checker.php';
session_checker();
?>


When I try to access the members only page I get the following error message:

Fatal error: Call to undefined function: session_checker() in /homepages/43/d70797741/htdocs/phpscripts/userlogin1.4/membersonly.php on line 3


So I'm obviously doing something wrong with my function. Can anyone see anything obviously wrong that I'm missing here??

Thanks
prendo is offline   Reply With Quote
Old 04-09-2003, 08:39 AM   #2 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
try this: http://www.codenewbie.com/forum/show...p?threadid=621
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 04-09-2003, 10:44 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
haha .. forgot about that one =)

i don't think i ever made it into a tutorial.
sde is offline   Reply With Quote
Old 04-09-2003, 12:54 PM   #4 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
you did not, but i figured out some session 'ish by lookin at that
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 04-10-2003, 08:48 AM   #5 (permalink)
prendo
Registered User
 
prendo's Avatar
 
Join Date: Jun 2002
Location: Leeds
Posts: 11
prendo is on a distinguished road
Hmmm! interesting. Thanks Admin & SDE; looks very useful.
prendo is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP N00b - How to check if a variable is set? or empty? helz MS Technologies ( ASP, VB, C#, .NET ) 3 11-04-2004 10:19 AM
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 02:36 AM
Using IsDate( ) to check for a Time value shs MS Technologies ( ASP, VB, C#, .NET ) 1 09-09-2004 12:03 PM
check if session variable is null? sde Java 3 07-07-2004 12:27 PM


All times are GMT -8. The time now is 02:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting