ellandrd
asked on
session problem
i have a webpage that if a registered user session is set or true let them view the full contents of the page else if a guest session is set or registered let them only view some of the contents on the page...
my problem is separating these out?
at the moment the site works great without try to include guest sessions.
so at the moment if you want to view the full contents of the page, you have to login and to do so you have to become a member... duh!
but what i want now is to allow unregistered users (guest) view the page too, but only some of the material, but if i try viewing the page without been login in, i get "please login"....
how do i overcome this?
my problem is separating these out?
at the moment the site works great without try to include guest sessions.
so at the moment if you want to view the full contents of the page, you have to login and to do so you have to become a member... duh!
but what i want now is to allow unregistered users (guest) view the page too, but only some of the material, but if i try viewing the page without been login in, i get "please login"....
how do i overcome this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
anybody?
ASKER
some more info that might help you find why i have a problem...
session.inc.php file:
========================== ========== ========== ========== ========== =========
<?php
require('e:\\domains\\q\\q uest-recru iting.com\ \user\\htd ocs\\globa ls\\classe s\\user.cl asses.php' );
session_start();
if(empty($_SESSION["user"] ->cid) || $_SESSION['guest'] == false)
{
?>
<script language="javascript">
top.location.href = "http://www.quest-recruiting.com/globals/includes/end.php?timeOut=1";
</script>
<?
}
if(!is_numeric($_SESSION[" user"]->ci d) || $_SESSION['guest'] == false)
{
?>
<script language="javascript">
top.location.href = "http://www.quest-recruiting.com/globals/includes/end.php?timeOut=1";
</script>
<?
}
$minutes = 20;
if ($_SESSION['guest'] == false || (time() - $_SESSION["timestamp"]) > $minutes*60)
{
?>
<script language="javascript">
top.location.href = "http://www.quest-recruiting.com/globals/includes/end.php?timeOut=1";
</script>
<?
}
else
{
$_SESSION["timestamp"] = time();
}
?>
index.php (login section)
========================== ========== ========== ========== ========== ==========
<?php
require('e:\\domains\\q\\q uest-recru iting.com\ \user\\htd ocs\\globa ls\\includ es\\sessio n.inc.php' );
if(isset($_SESSION['user'] ->cid))
{
header("Location: main.php");
}
....
// form so user can login...
?>
index.php
========================== ========== ========== ========== ========== ====
<?php
require('e:\\domains\\q\\q uest-recru iting.com\ \user\\htd ocs\\globa ls\\includ es\\db.inc .php');
$link_id = db_connect();
require('e:\\domains\\q\\q uest-recru iting.com\ \user\\htd ocs\\globa ls\\includ es\\sessio n.inc.php' );
include_once('e:\\domains\ \q\\quest- recruiting .com\\user \\htdocs\\ globals\\c lasses\\us ersOnline. class.php' );
if (empty($_SESSION['user']-> cid))
{
$_SESSION['guest'] == true;
$welcome = "Welcome guest!";
}
else
{
$welcome = (empty($_SESSION['user']-> firstname) ) ? "Welcome ".$_SESSION['user']->first name : "Welcome ".$_SESSION['user']->first name;
}
?>
please i need some help!
Ellandrd
session.inc.php file:
==========================
<?php
require('e:\\domains\\q\\q
session_start();
if(empty($_SESSION["user"]
{
?>
<script language="javascript">
top.location.href = "http://www.quest-recruiting.com/globals/includes/end.php?timeOut=1";
</script>
<?
}
if(!is_numeric($_SESSION["
{
?>
<script language="javascript">
top.location.href = "http://www.quest-recruiting.com/globals/includes/end.php?timeOut=1";
</script>
<?
}
$minutes = 20;
if ($_SESSION['guest'] == false || (time() - $_SESSION["timestamp"]) > $minutes*60)
{
?>
<script language="javascript">
top.location.href = "http://www.quest-recruiting.com/globals/includes/end.php?timeOut=1";
</script>
<?
}
else
{
$_SESSION["timestamp"] = time();
}
?>
index.php (login section)
==========================
<?php
require('e:\\domains\\q\\q
if(isset($_SESSION['user']
{
header("Location: main.php");
}
....
// form so user can login...
?>
index.php
==========================
<?php
require('e:\\domains\\q\\q
$link_id = db_connect();
require('e:\\domains\\q\\q
include_once('e:\\domains\
if (empty($_SESSION['user']->
{
$_SESSION['guest'] == true;
$welcome = "Welcome guest!";
}
else
{
$welcome = (empty($_SESSION['user']->
}
?>
please i need some help!
Ellandrd
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
when user logs in, i compare username/password against that in the DB. if true, i register a session contain cid,username, firstname.
then on each page i wish to allow that user to view, i check for session values... like cid or username etc.
in use your solution, im not too sure how i include it....
eg.
main.php
<?php
require('../globals/includ
if ($_SESSION['user']->userna
{
echo "Logged In As ".$_SESSION['user']->first
// show admin material here
}
else if ($_SESSION['user']->userna
{
echo "Logged In As ".$_SESSION['user']->first
// show registered users material here
}
else
{
echo "Welcome Guest";
// show non-registered users material here
}
?>
session.inc.php just checks if session was set or not...