Can't keep session continuous between all pages using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rammohan518
Forum Newbie
Posts: 3
Joined: Sun Jun 22, 2014 10:52 am

Can't keep session continuous between all pages using php

Post by rammohan518 »

I have created a session in php where users log in and their data is transferred in all the pages.it looks like this

Code: Select all

<?php ob_start();
session_start();
error_reporting(0);
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
include 'cw-config.php';
if($_SESSION[userid]!='')
{
$details=mysql_fetch_array(mysql_query("select * from register where guid='$_SESSION[userid]'"));
}
?>
It works on all pages except on this one even though i wrote the code in same manner as above one.it looks like this

Code: Select all

<?php ob_start();
session_start();
error_reporting(0);
include 'cw-config.php';
extract($_POST);
extract($_GET);
$_SESSION['url'] = $_SERVER['REQUEST_URI'];

if($_SESSION[userid]!=''){ 
$details=mysql_fetch_array(mysql_query("select * from register where guid='".$_SESSION["userid"]."'"));
}
$shopdata=mysql_fetch_array(mysql_query("select * from shop where guid='$shopid'"));
?>
Kindly visit:http://rewardsinn.com the problem is with categories/stores when selected from dropdown menu the session isn't getting transferred I am new to this coding and had redo everything as we were cheated by a designer.it was working fine till yesterday.Kindly help me in this.Once sign in and check to know the problem.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Can't keep session continuous between all pages using ph

Post by Celauran »

What's the problem? Anything in your error logs?
rammohan518
Forum Newbie
Posts: 3
Joined: Sun Jun 22, 2014 10:52 am

Re: Can't keep session continuous between all pages using ph

Post by rammohan518 »

Kindly visit rewardsinn.com
sign in with fb,a session is created with ur user name and select any item from categories or stores it shows no session.whereas if u click on all the other menu items it shows session even though i am using the same code as above
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Can't keep session continuous between all pages using ph

Post by Celauran »

rammohan518 wrote:Kindly visit rewardsinn.com
sign in with fb
Not going to happen.
rammohan518 wrote:a session is created with ur user name and select any item from categories or stores it shows no session.whereas if u click on all the other menu items it shows session even though i am using the same code as above
I'd recommend turning error reporting back on, at least in a development environment, and see what errors are being displayed/logged. That should give you some indication as to what's going wrong and where. Sessions need to be initiated before headers are sent, so before any output is sent to the browser, and just whitespace has been known to cause problems.
rammohan518
Forum Newbie
Posts: 3
Joined: Sun Jun 22, 2014 10:52 am

Re: Can't keep session continuous between all pages using ph

Post by rammohan518 »

u can also register with any fake id and check..i am new to development so help me..just give any false email...no verification is present is website..requesting so that u will understand my problem..
and regarding what u said should put session start before everything(ob report)
Post Reply