Main Contents

Forum

Nam Tran Ybarra @ July 6, 2008

You must be logged in to post

Search Forums:


 






How to tell a member is actually logged in

UserPost

9:33 pm
August 18, 2008


newsblaze

newsblaze

Member

posts 54

How can I tell that someone is actually logged in, when calling an external application?

I want to allow access to an application but only if the member is logged in to MS.

- or if they are not logged in, I'll ask for the login name and password

If they are logged in, I don't want to ask for it a second time.

There is a PHPSESSID but how can I tell it is active?

Obviously, from my application, I can read the MS database to check the password, if I have the login name, but anyone could send that login name to the app. (right now, __username__ isn't available, but I can get __MEMBER_NAME__ )

I don't see a database entry that tells me they are logged in.


NewsBlaze.com

7:08 pm
September 11, 2008


tiggerific

Australia

Moderator

posts 16

Knowing whether a member is currently logged in or not, is not stored in the database. The information is stored in session variables.

You will need to check the SESS_MEMBERSHIP_ID and the SESS_MEMBER_ID variables to cover all bases. I use the following PHP code to send a user to the login page if they are NOT logged in. You would simply add an "else" statement to continue to your external application:

—————————————

//start the sessions
session_start();

//specify the script location (root dir)
DEFINE("__VROOT_DIR__","http://yourdomain.com/installpath");

//include the memberspeed global variables so you don't have to recreate them all
require("/absolutepathtoinstallationdirectory/includes/global.php");

 //check if the member is already logged in nor not
 if(!isset($SESS_MEMBER_ID) || $SESS_MEMBERSHIP_ID=="" || !isset($SESS_MEMBERSHIP_ID)){
   //redirect to login if not logged in
   header("Location:".__VROOT_DIR__."/members/login.html");
 }else{
   //go to your external application or enter additional code here
 } 

——————————-

Items above in black are comments, items in blue require changing to your own site's details.


Visit Ezy Template for professional MemberSpeed Templates ready to go!



About the MemberSpeed How To Tutorials forum

Most Users Ever Online:

47


Currently Online:

6 Guests

Forum Stats:

Groups: 2

Forums: 8

Topics: 255

Posts: 652

Membership:

There are 360 Members

There has been 1 Guest

There is 1 Admin

There are 6 Moderators

Top Posters:

newsblaze – 54

macknox – 23

jamesreilly – 22

mknowles – 16

cj_adminpro – 12

resellit – 12

Administrators: Nam Tran Ybarra (258 Posts)

Moderators: David Dixon (40 Posts), robkiernan (27 Posts), tiggerific (16 Posts), Paul Inglis (5 Posts), joe (4 Posts), Nick_Sanders (0 Posts)