Jump to content
TNG Community
garybakker

(SOLVED) Session variables "mypersonID" and "mygedcom" are null and they shouldn't be when logged in

Recommended Posts

garybakker

 

I am trying to customize my site using the MyPage/MyFamily/MyAncestry changes described by Merv in this thread:

 
I've got the code installed but the links are not working, even on the home page. They depend on $_SESSION variables. Specifically that $_SESSION['mypersonID'] and $_SESSION['mygedcom'] are not null. In debugging I dumped the session variables and both of the ones mentioned above *are* null. And yes, I am logged in.
 
Based on some experimentation with the original links that work, it appears I might not need $_SESSION['mygedcom']. I think if I can retrieve the personID of the person logged in, I can get this to work.
 
Has something changed with v12 that might cause this issue? Or is it my server host (SimplyHosting)?
 
My site (running v12) which still has the original links along with the "MyPage etc" links:
 
My server (if it matters):
I am using SimplyHosting.
 
Here is the code in index.php that creates the MyPage link and depends on those variables. Because the first part of the if statement is false it sends me to a login screen.
<li>
<a href="
<?php 
if ( $_SESSION['mypersonID'] != "" && $currentuser && $_SESSION['mygedcom'] != "") 
{
$xerxxTarget = $cms['tngpath'] . "getperson.php?personID=" . $_SESSION['mypersonID'] ."&amp;tree=" . $_SESSION['mygedcom'];
echo "{$cms['tngpath']}$xerxxTarget";
}
else  
{
echo "{$cms['tngpath']}login.php"; 
}
?>
"><span class="l"></span><span class="r"></span><span class="t">&#128100; My Page</a></span></a>
</li>

Best regards,

Gary

Share this post


Link to post
Share on other sites
manofmull

Gary

I use that code and it works very well. The three homepage links are for logging in.

Anyone who uses those links must be in your site database. You add their page ID in Admin/Users. See image 1

I tweaked it a little to get the look in image 2

Image2.jpg

 

Image1.jpg

 

Share this post


Link to post
Share on other sites
XerxX

Hi Gary,

 

I just now downloaded and installed my Open My Page mod v10.0.0.4b (your code snippet is from there, right?) in my TNGv12.3 site (localhost) and it shows in the Info menu and the "innermenu" (beside log in and Edit Profile) when I'm logged in as a member of the tree (I have my own getperson page):

ToGaryTNGforum.png

("Öppna min sida" = "Open my page" in Swedish - this is a Swedish-only site)

It works when clicked.
I suppose you were logged in as a member of the tree when you tested it (you have to be, for the links to work). In that case, there is some other problem with your $_SESSION variables, but it's not my mod.

I wish I could help you more but why those variables are empty is beyond my competence.

 

Best regards,

Erik

Share this post


Link to post
Share on other sites
XerxX

Gary, I just checked the source code for my mod (Open My Page).

Your snippet is not from there: I don't use the log in page because to see the links you have to be logged in and have your own getperson page.

If you're not logged in or you don't have a person ID (your own getperson page) the links ("Open my page") are just not there, so there is no reason to re-direct to login.php.

 

Regards,

Erik

Share this post


Link to post
Share on other sites
manofmull

Erik

In my own setup, the links are visible to everyone, whether logged in or not.

MyPage etc. are quick-links for my members to get to their own family, and "replace" the normal homepage log in link.

I made it optional to be included in the site database and the links are only for those who chose to do so (hence the red text line in image 2 above).

I call this the Relationship Feature. Any member can see anyone's relationship to the default ID 1. When they opt in, they themselves replace the default ID 1 and the relationship is calculated to each opted-in member: they love it.

Share this post


Link to post
Share on other sites
XerxX

Yeah, the thing was that I woke up and saw my name in a variable and thought it was my mod.

So I got worried and tried it immediately instead of reading through the post. When I was really awake I came to my senses and wrote the second post.

I don't use the mod at my 12.3 site ("botebygden" in my sig) because it's completely open.

Sorry if I confused anyone, but I think I was confusing myself even more.

/Erik

Share this post


Link to post
Share on other sites
garybakker

Wow. Original Poster here. There is a lot to absorb and examine in your responses. 

I deeply appreciate your assistance. I need some time to look at things. I'll post here again when I figure out what the best course of action is.

Regards,
Gary

Share this post


Link to post
Share on other sites
garybakker
12 hours ago, XerxX said:

Gary, I just checked the source code for my mod (Open My Page).

Your snippet is not from there: I don't use the log in page because to see the links you have to be logged in and have your own getperson page.

If you're not logged in or you don't have a person ID (your own getperson page) the links ("Open my page") are just not there, so there is no reason to re-direct to login.php.

 

Regards,

Erik

a) Thanks. The code I am trying to get to work was written by Merv and appeared in a Forum thread (I linked to it in my OP). I reached out to him but I have not received any response.

b) I will take a look at your mod. Would I be able to modify it to display a fan chart instead of going to "My Page"?

c) The problem I'm having is I am testing the php code and the links don't work even when I am logged in.

d) Interesting approach to only show the special links when and if someone is already logged in. I'm not sure what I would display to people who are not logged in though. I suppose I could default to me, the owner and administrator.

Regards,
Gary

Share this post


Link to post
Share on other sites
garybakker
14 hours ago, manofmull said:

Gary

I use that code and it works very well. The three homepage links are for logging in.

Anyone who uses those links must be in your site database. You add their page ID in Admin/Users. See image 1

I tweaked it a little to get the look in image 2

Image2.jpg

 

Image1.jpg

 

a) Thanks. I realize that the links are only supposed to work with logged in users. That's my problem though. The links don't work even when I am logged in.

b) Would you be willing to post the code excerpt that shows the construction of your MyPage, etc links? I'd like to see how you are doing it compared to the code from Merv I'm trying to use.

c) Like you, my registered family members would love the feature to be able to go directly to their own information, and be able to explore from there.

d) You mentioned in a later post that your MyPage, etc links show up even if the user is not logged in. What happens exactly when they click on one of the links?

Regards,
Gary

Share this post


Link to post
Share on other sites
manofmull

Gary

You have it wrong! They do NOT work for logged in users.

The links are FOR logging in directly to the user's page/family. If you have logged in from the normal link, the personal links will not work!  As I pointed out above, they are shortcuts to get to a user's page/family, and that user MUST be in the database (their ID number per above inserted in Admin/Users).

Share this post


Link to post
Share on other sites
XerxX

Hi Gary,

My mod and Merv's have different purposes - my mod is just opening "my page" - that can be any page that you can build a link to using the $_SESSION variables.

But it requires you to be logged in and have a Person-ID (= a getperson.php page). Otherwise one or more of the $_SESSION and $currentuser variables are empty. If you check my code you will see that it's as simple as Create the link ONLY IF the $_SESSION and $currentuser variables are > "" - otherwise skip it.

Regards,

Erik

Share this post


Link to post
Share on other sites
manofmull

Gary

Code was almost exactly as Merv had posted. I just made the links horizontal as opposed to vertical.

Share this post


Link to post
Share on other sites
garybakker
39 minutes ago, manofmull said:

Gary

You have it wrong! They do NOT work for logged in users.

The links are FOR logging in directly to the user's page/family. If you have logged in from the normal link, the personal links will not work!  As I pointed out above, they are shortcuts to get to a user's page/family, and that user MUST be in the database (their ID number per above inserted in Admin/Users).

I clearly misunderstood your post. Sorry.

OK. After a bunch of research on user IDs prompted by your posts, I've determined that for some reason my own Administrative ID was not active. Don't know how that happened.  ::insert appropriate emoji here, maybe this one::  🙄

I had an ID of course, but the system wasn't really fully set up somehow and wasn't recognizing my credentials. Checking the users who I've assigned usernames and passwords, there were two out of 19 that had this same issue. Since I was of course testing with my own userID, things were not working right.

After the fix, the links are working and of course the $_SESSION into dumps are also now correctly showing the appropriate info.

Whew.

manofmull and XerxX, thank you for your patient assistance. This thread is now complete.

Best regards,
Gary

 

Share this post


Link to post
Share on other sites
garybakker
5 minutes ago, XerxX said:

Hi Gary,

My mod and Merv's have different purposes - my mod is just opening "my page" - that can be any page that you can build a link to using the $_SESSION variables.

But it requires you to be logged in and have a Person-ID (= a getperson.php page). Otherwise one or more of the $_SESSION and $currentuser variables are empty. If you check my code you will see that it's as simple as Create the link ONLY IF the $_SESSION and $currentuser variables are > "" - otherwise skip it.

Regards,

Erik

Thanks! I appreciate the follow-up.
Gary

Share this post


Link to post
Share on other sites
garybakker
3 minutes ago, manofmull said:

Gary

Code below almost exactly as Merv had posted. I just made the links horizontal as opposed to vertical.

<!–Start Personalised MY PAGE Link
Edit link name as required (default MY PAGE)–>
<p align="center"><a href="<?php if ( $_SESSION['mypersonID'] != "" && $currentuser && $_SESSION['mygedcom'] != "") {
$xerxxTarget = $cms['tngpath'] . "getperson.php?personID=" . $_SESSION['mypersonID'] ."&amp;tree=" . $_SESSION['mygedcom'];
echo "{$cms['tngpath']}$xerxxTarget";}
else  echo "{$cms['tngpath']}login.php"; ?>
">&#128100; My Page</a></span></a>
<!–End Personalised MY PAGE Link–>
&nbsp  &nbsp
<!–Start Personalised Family Chart Link
Edit link name as required (default MY FAMILY)–>
<a href="<?php if ( $_SESSION['mypersonID'] != "" && $currentuser && $_SESSION['mygedcom'] != "") {
$xerxxTarget = $cms['tngpath'] . "familychart.php?personID=" . $_SESSION['mypersonID'] ."&amp;tree=" . $_SESSION['mygedcom'];
echo "{$cms['tngpath']}$xerxxTarget";}
else  echo "{$cms['tngpath']}login.php"; ?>
">&#128100; My Family</a></span></a>
<!–End Personalised Family Chart Link–>
&nbsp  &nbsp
<!–Start Personalised Ancestor Chart Link
Edit ancestor chart type and link name as required (default verticalchart.php & MY ANCESTRY)–>
<a href="<?php if ( $_SESSION['mypersonID'] != "" && $currentuser && $_SESSION['mygedcom'] != "") {
$xerxxTarget = $cms['tngpath'] . "verticalchart.php?personID=" . $_SESSION['mypersonID'] ."&amp;tree=" . $_SESSION['mygedcom'];
echo "{$cms['tngpath']}$xerxxTarget";}
else  echo "{$cms['tngpath']}login.php"; ?>
">&#128100; My Ancestry</b></a></span></a><br/>
<!–End Personalised Ancestor Chart Link–>

Thanks for the follow-up! I really appreciate it. I posted the solution to my problem at about the same time you kindly provided the code you are using. Thanks again!
Gary

Share this post


Link to post
Share on other sites
manofmull

Gary

Glad you are sorted.

Please edit your post heading, preceded with SOLVED

Share this post


Link to post
Share on other sites
garybakker
Just now, manofmull said:

Gary

Glad you are sorted.

Please edit your post heading, preceded with SOLVED

Ah. Thanks. I didn't know about that. As you can tell, I'm a bit of a novice. I appreciate the guidance.
Gary

Share this post


Link to post
Share on other sites
manofmull

Gary

I just took a look at your homepage and notice you have the "My" links on the menu bar.

Did you insert the code in Admin/Template Settings to get the links there? (I use that menu bar for a site headline text message)

If you don't mind me saying so, your homepage text for "The Site" is only good for users who are in your site database: i.e. registered users/members. The links are useless to the general public, as these are links to log in from. Public users can search from the Search fields top right. I suggest you have the "My" links aimed at registered users, but that's up to you.

If you have a closed or semi-open site i.e. all or some users requiring to log in, ask your hosting provider to make your site https. My site is closed i.e. all user members must log in, and it's https via Let's Encrypt.

Share this post


Link to post
Share on other sites
garybakker
33 minutes ago, manofmull said:

Gary

I just took a look at your homepage and notice you have the "My" links on the menu bar.

Did you insert the code in Admin/Template Settings to get the links there? (I use that menu bar for a site headline text message)

If you don't mind me saying so, your homepage text for "The Site" is only good for users who are in your site database: i.e. registered users/members. The links are useless to the general public, as these are links to log in from. Public users can search from the Search fields top right. I suggest you have the "My" links aimed at registered users, but that's up to you.

If you have a closed or semi-open site i.e. all or some users requiring to log in, ask your hosting provider to make your site https. My site is closed i.e. all user members must log in, and it's https via Let's Encrypt.

Weird. I thought I responded to this. Weird. Anyway ...

Yep. My intent was to limit the usage of the site to registered users (family members). Although based on your thoughts, I'm experimenting with adding a "general public" link in front of the MyPage links.

I'll provide a detail list of what I did to get the links in my header in a separate post.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×