/    Sign up×
Community /Pin to ProfileBookmark

Can’t keep session continuous between all pages using php

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=php]<?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]'”));
}
?>[/code]

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=php]<?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'”));
?>[/code]

Kindly visit:[url]http://rewardsinn.com[/url] 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.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJun 22.2014 — how about the missing quotes on userid in your first reference above? if you have some other constant/var named 'userid' then this session ref will not work as expected.

(all literal array indices SHOULD be in quotes).
Copy linkTweet thisAlerts:
@rammohan518authorJun 22.2014 — I tried what u said and changed but the problem remains the same.session isn't getting recorded.visit rewardsinn.com,

ID:ram

pwd:123

after logging in check any category/shop u wil find the problem
Copy linkTweet thisAlerts:
@NogDogJun 22.2014 — One possible gotcha is if you sometimes link to a page or form action with a www sub-domain and sometimes don't. You can avoid this issue if you set the session.cookie_domain configuration parameter to be ".yourdomain.com" (note the leading dot). (This could also be done via session_set_cookie_params() in a config file that always gets called before you do your session_start().)
Copy linkTweet thisAlerts:
@rammohan518authorJun 23.2014 — Thanks...i have removed the www part its working now
×

Success!

Help @rammohan518 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...