1 (edited by 2013-09-03 06:53:56)

Topic: content for users only

Hi
i am having trouble with a simple thing, basicly i want some content on my site that will work like this

if (verify if user logged in on CN){
Display things visible only for logged in
}else{
Display things visible only for not logged in
}

I was looking at some loginboxes etc that will have this loop, but propably i am to dumb in php to see it

Please help me with this one
thank you

Re: content for users only

This may work.
Check for the cutenews cookie like this:

 
                  if (isset($_COOKIE['session']) && $_COOKIE['session'])
    {
    $category = 11;
 include("cutenews/show_news.php");
    }
    else
    {
$category = 7;
 include("cutenews/show_news.php");
    }

Re: content for users only

Thanks for replying, unfortunetly your code does not work hmm
This is how its displaying

                  if (isset($_COOKIE['session']) && $_COOKIE['session'])
    {
is always shown
    }
    else
    {
is never shown
    }

i may add that i am modificating CN so index isnt the main page, its news.php
you may see my webpage here Grafika.cba.pl, its in polish like some of the CN i maintained to translate. I am working now on the login box on the top, so login is shown when someone is not logged in, and if someone is logged they have a logout button + some other links.

Re: content for users only

Just tested.
Works O.K. here.
Are you clearing cookies from your browser between tests?

5 (edited by 2013-09-03 15:50:11)

Re: content for users only

yes i do, does not work for me :S any clue why?

EDIT:
After making few tests today i think it works, but not the way i wish it would. It is missing one part i guess. At the moment when i login i get the content for users only, but when i logout the content is still visible. How to make the content go back to the old way? So when i logout i see again my login panel?

Re: content for users only

When you log out the cookie is not being cleared?
Test by shutting the browser down and loading the page  again.

7 (edited by 2013-09-03 16:31:05)

Re: content for users only

I did, when i close the browser i get the login form again. But if i don't i am forever logged in.
Now i even made my own logout, here is the code. Both CN logout and my are not working to solve this.

<?php
session_destroy();
unset($_COOKIE);
header("Location: /index.php");
?>

8 (edited by 2013-09-03 20:50:44)

Re: content for users only

http://support.microsoft.com/kb/224304Refers to older browser but may still apply.Have you tried a different  browser?
http://support.microsoft.com/kb/223799/EN-US

9 (edited by 2013-09-04 03:49:44)

Re: content for users only

I think it's not the browsers fault, i use google chrome.

edit:

i noticed that anything i put in login panel changes it to "only logged in view" after pressing login even though i didnt fill the fields. However it does not login to the builtin CN panel. So i decided to privde you with all i have:

<?php
        if (isset($_COOKIE['session']) && $_COOKIE['session'])
{
 
        echo'<table width="325px" height="100px" cellspacing="12px" cellpadding="0px" style="border: 0px dashed white; margin: 2px; font-size: 11px;"><tr><td style="text-align: right; line-height: 20px;" width="118px">[url=n]Ustawienia Konta[/url]
[url=#">Strefa Użytkownika</a]Wyloguj[/url]
</td><td style="border-left: 1px dashed white; padding-left: 10px;">[img]gfx/ok.png[/img]
<span>[img]gfx/q.png[/img] $num = Rand (1,7); 
 switch ($num)
 {
 case 1:
 echo "Logowanie jest w fazie beta i nie działa prawidłowo.";
 break;
 case 2:
 echo "Niektóre strony nie ładują się jeszcze poprawnie.";
 break;
 case 3:
 echo "Niektóre podstrony jeszcze nie istnieją w naszym systemie.";
 break;
 case 4:
 echo "Wejdź w edycje profilu aby zmienić hasło lub ustawić sobie awatar.";
 break;
 case 5:
 echo "W dziale [url=c]kontakt[/url] jest formularz do kontaktu przez który można zgłaszać feedback.";
 break;
 case 6:
 echo "Dokładnie zapoznaj się z [url=r]regulaminem[/url] zanim zaczniesz korzystać z serwisu.";
 break;
 case 7:
 echo "W strefie użytkownika znajdziesz specjalne materiały autorstwa grafika.cba.pl tylko dla tych którzy mają u nas konto.";
 
 }
        
        echo'</span></td></tr></table>
';
    }
    else
    {
        
echo'<table height="20px" style="margin-top:10px;" cellspacing="0px" cellpadding="0px" border="0px"><tr valign="baseline"><td><form action="news.php" method="post"><input type="text" name="username" class="undertext">
<input type="password" name="password" class="undertext"></td><td style="padding: 5px; line-height: 22px;">[url=r]Zgubione hasło?[/url]
[url=r]Zarejestruj siÄ™[/url]</td></tr>
        <tr><td colspan="2">
        <input type="hidden" name="action" value="dologin">
        <input type="submit" class="buttonx" value="Login"></form>
        </td>
        </tr>
        </table>
        


        ';
        
    }
            
?>

Please somebody tell me where am i making a mistake, what am i not seeing?