Jump to content
hariskar

How can I avoid registered user content visible to others when copy/paste url?

Recommended Posts

With php registered users have access, each to their own results when they click to www.site.com/results. The results are pdf. So when a user clicks on results he can see a page with the links to all the pdf of his results. The problem is that if someone copies and pastes this link he can also see the results even if he is not registered. How could I avoid this? Here is the code:

Thank you!

<?php
if ($_SESSION['username']=="user1") {
readfile("https://www.site.com/results/user1.html");
} elseif($_SESSION['username']=="user2") {
readfile("https://www.site.com/results/user2");
} else { ?>
<p>Αν θέλετε να μπορείτε να βλέπετε τα αποτελέσματά σας online και να τα κατεβάζετε σε μορφή pdf παρακαλώ <b>ενημερώστε μας</b> προφορικά, με email ή συμπληρώνοντας τη <a href="forma
-epikoinonias">φόρμα επικοινωνίας</a> και <a href="https://www.site.com/user/register">εγγραφείτε στην ιστοσελίδα μας</a>.</p>
<?php } ?>

 

Edited by hariskar

Share this post


Link to post
Share on other sites

You've stated that you have a page that requires users to be logged in to view.

Could you duplicate the code that checks if they're logged in and place it before the code you've posted?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...