Jump to content

Please help me with $_SESSION['user_logged']


smartguyin

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]

Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

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.