Jump to content

Archived

This topic is now archived and is closed to further replies.

smartguyin

Please help me with $_SESSION['user_logged']

Recommended Posts

The website has login system but some pages can be accessable without login and some pages like logging to control panel or adding post for which logging in is compulsory....

Or for the pages where loggin in is not compulsory.... means people can see the content without loggin in i am using the [b]include "user.inc.php";[/b] in those pages....

And pages like control panel and adding post is compulsory i am using [b]inlcude "auth_user.inc.php";[/b]  Soo that if the user is not logged in they will be directed to user_login.php page to LOG IN.

MY PROBLEM >>>>>>>>>>  I am using sidebar.php page for my side column.... When the User is logged in, it shows the logged in username in side bar using "$_SESSION['user_logged']" in sidebar.php page and some links to control panel....... 

NOW when the user is acually logged in.... the sidebar shows the name of the username logged in where i am using user.inc.php but it doesn't shows the username of logged in user in control panel and add post page where i am using auth_user.inc.php....... Please help me to find out why am i not able to see the username in sidebar when i am using auth_user.inc.php or while loggin into control panel....

auth_user.inc.php >>>>>>>>> page
[code]<?php
session_start();
if ((isset($_SESSION['user_logged']) && $_SESSION['user_logged'] != "") ||
(isset($_SESSION['user_password']) && $_SESSION['user_password'] != "")) {
$name = ($_SESSION['user_logged']);
session_register($_SESSION['user_logged']);
$name = $_SESSION['user_logged'];

$side = 1;
} else {
$side = 0;
$redirect = $_SERVER['PHP_SELF'];
header("Refresh: 5; URL=http://localhost/est/login/user_login.php");
echo "You are not currently no logged in, we are redirecting you, be patient!<br>";
echo "(If your browser doesn't support this <a href=\"http://localhost/est/login/user_login.php\">Click Here</a>)";
die();
}
?>
[/code]

My user.inc.php >>>>>>>>>>>>>.page

[code]<?php
session_start();
if ((isset($_SESSION['user_logged']) && $_SESSION['user_logged'] != "") ||
(isset($_SESSION['user_password']) && $_SESSION['user_password'] != "")) {
$side = 1;
} else {
$side = 0;
//do nothing
}
?>[/code]

Share this post


Link to post
Share on other sites
I've read thru your post about 3 times but i'm still not quite getting what your exact problem is and also your code

$name = ($_SESSION['user_logged']);
session_register($_SESSION['user_logged']);
$name = $_SESSION['user_logged'];


why are you setting it before and after session_register?

and

if ((isset($_SESSION['user_logged']) && $_SESSION['user_logged'] != "") ||
(isset($_SESSION['user_password']) && $_SESSION['user_password'] != "")) {

shouldn't that be

if ((isset($_SESSION['user_logged'])) && ($_SESSION['user_logged'] != "")) || ((isset($_SESSION['user_password'])) && ($_SESSION['user_password'] != ""))) {


Regards
Liam

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.