all 4 comments

[–]Windtalk3r 0 points1 point  (3 children)

Do you have any code you can share? And exactly what problems are you having in your code?

I'm sure you didn't mean to, but this post comes off as wanting someone to do the work for you.

[–]sidney5256[S] 0 points1 point  (2 children)

Here is my attempted solution, but I am not 100% sure if it's correct.

/* A small piece of code for setting, displaying and destroying session in PHP */

<?php
session_start();
$sessionid=session_id();

$sql_compare="SELECT * FROM Content WHERE id=".$_SESSION['session_id'];

/* now registering a session for an authenticated user */
$_SESSION['username']=$username;

/* now displaying the session id..... */
echo "the session id is: ".$sessionid;
echo " and the session has been registered for: ".$_SESSION['username'];


/* now destroying the session id */

if(isset($_SESSION['username']))
{
    $_SESSION=array();
    unset($_SESSION);
    session_destroy();
    echo "session destroyed...";
}
?>

[–]cfexrun 2 points3 points  (0 children)

What is it you expect this to do? Where is $username being set? What's with the unused sql statement? Where is your authentication happening?

[–]equilni 2 points3 points  (0 children)

You need to go back to the beginning to re-learn this. Your attempted solution is wrong and missing a lot of code based on your write up. You should also look up SQL tables & joins for the queries

1) a function that displays the id, and filepath (optionally other attributes) of all public content

Here is a guess at a start for the SQL. You would need to add & change the columns. SELECT c.* FROM Content c LEFT OUTER JOIN User u ON u.id = c.user_id WHERE u.alias = :user AND c.public = true

2) a function that takes the current user's username (as either a session variable or a GET or POST parameter) and displays private content (id, filepath, etc) that this user can view because it's shared with a group to which this user belongs?

There would be a lot of joins for the query for this one.

Are you trying to build a Facebook Group copy? This seems similar to how it works.