473,692 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Losing Session Variables

I place a session_start () within php tags at the top of one of my pages.
Then I get a value and placed it in a php variable called $clientid.

After that, I register the session variable using: session_registe r
("clientid") ; So far o.k. Two pages later, I'm trying to get the value of
that session variable using:

$viewerclientid = $_SESSION['client_id']; The problem that I'm having is
that while this works in some computers, other users

are having problems. It seems that they lose the value of this session
variable. Both users, the ones that run this successfully and the ones that
don't seem to be using

IE 6 as a browser on the same version of windows (XP).

Thanks.
Jul 17 '05 #1
4 15419
I had the same problem when writing my site. I found that it worked
best by putting <?php session_start() ; ?> all by itself on the top of
every page (the very first line before anything else). After that,
everything seemed to work out much better.

Example:
<?php session_start() ; ?>

<?php
// Other PHP Code Here
?>

Jul 17 '05 #2
"paddy_nyr" <mp****@yahoo.c om> wrote in message
news:39******** *****@individua l.net...
I place a session_start () within php tags at the top of one of my pages.
Then I get a value and placed it in a php variable called $clientid.

After that, I register the session variable using: session_registe r
("clientid") ; So far o.k. Two pages later, I'm trying to get the value of
that session variable using:
I would recommend against using session_registe r - see warning about
register_global s here: http://php.net/session_register

Instead you should simply put things in $_SESSION. If you don't want to
type out $_SESSION['client_id'] each time you can still do

$client_id = &$_SESSION['client_id'];

Changes to $client_id will be recorded in the session record.

$viewerclientid = $_SESSION['client_id']; The problem that I'm having is
that while this works in some computers, other users
are having problems. It seems that they lose the value of this session
variable. Both users, the ones that run this successfully and the ones
that
don't seem to be using
IE 6 as a browser on the same version of windows (XP).


Are you using redirects anywhere? You should called session_write_c lose()
beforehand, as in:

session_write_c lose();
header('Locatio n: http://mysite.com/somepage.php');
exit(0);

If you do not write out the session before redirecting the browser, there is
a chance that the second page will start up, and read in the session record,
before the first page has finished shutting down and writing the session
record, causing lost session data. I've experienced this before.

HTH,
-Josh
Jul 17 '05 #3
"paddy_nyr" <mp****@yahoo.c om> wrote in message
news:39******** *****@individua l.net...
I place a session_start () within php tags at the top of one of my pages.
Then I get a value and placed it in a php variable called $clientid.


Wait, at the top of *one* of your pages? You know you have to have it at
the top of all your pages, right?
Jul 17 '05 #4
pete1952
1 New Member
Thanks so much for your entry. It worked for me and I've been looking all day for the answer. I use Dreamweaver 8 and it did not have a clue.
Thanks again! Pete Smith


I had the same problem when writing my site. I found that it worked
best by putting <?php session_start() ; ?> all by itself on the top of
every page (the very first line before anything else). After that,
everything seemed to work out much better.

Example:
<?php session_start() ; ?>

<?php
// Other PHP Code Here
?>
Mar 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7787
by: vivek | last post by:
Do any of you guys have any idea what might be the reason for losing session variables, i was working on a page where i had to stroe a array in a session(trust me that was the only 'way' i could imagine doing it), and i am losing the session variable, its just returning empty values...does any one has any ideas?
1
2779
by: Scott Lyon | last post by:
I'm maintaining (read: I didn't write it, nor do I have the time to spend to rewrite it) an application that is suddenly giving me grief. The reason I say suddenly, is because we're in the process of transitioning the server on which it runs from Microsoft Windows 2000 Server, to 2003 server (going from IIS 5 to IIS 6). This problem hasn't really occurred on the 2000 server machine, but it's happening MUCH more on the new 2003 box (not...
2
3304
by: Terry | last post by:
When launching our application with Internet Explorer already opened, but not pointing to our web server, the session variables disappear. If you open I.E. after launching our app, it works fine. It also works fine if you have the option set to 'Reuse Windows for Lauching Shortcuts' checked in the I.E. properties and launch our app from a shortcut, but it fails it you launch it from the I.E. favorites or some other method that won't take...
0
453
by: mbosco51 | last post by:
I know this is a common thread, but I seem to be losing session variables on my website. I read through everything I could find, including this link: http://aspfaq.com/show.asp?id=2157, but cannot seem to fix the problem. First so history... we were getting a lot of reports of session loss on a particular page. Eventually we tracked it down to the fact that we were launching pop up windows, which do not always share the same state. ...
2
2349
by: GFuller | last post by:
- We have 2 aspx pages in a .NET project. The first sets a session variable and has a button that when clicked performs a 'redirect' to the second page which then reads the session variable. Problem: This always works fine on the localserver and through the IDE. But when the application is put onto a www website, the following occurs; - If you browse to the site using the IP address, session variables work fine
2
2354
by: M | last post by:
Have you come accross the issue described below or know more about it? We have come accross a situation where session variables are getting lost temporarily but come back again if user reloads the same page. Found that whenever the server has to load/compile (not sure which) the website dlls (for eg the first time a page is requested from a website) and if the browser makes a subsequent request for another page (for eg the first page...
3
1984
by: ACaunter | last post by:
Hi all, I'm wondering why I keep losing my session variables all the time. I've set the timeout to be an hour, but for some reason randomly i keep losing everything.. what could be causing this?? also, is there a way to automatically go back to the login page as soon as the sessions have expired or are lost. thanks
2
1444
by: Wim Geukens | last post by:
All, We're experiencing a very strange session variable problem. We've got a running version of our site at www.mysite.com, which points to c:\mysite in IIS 5 This same site is also reachable via test.mysite.com, because we specified it in the "Advanced multiple Web Site configuration" dialog box. So it's basically the same website. Now, on our site we have a datagrid with paging enabled.
2
2598
by: competitions | last post by:
I notice that others have had this problem, after scanning Google, but I couldn't find any solution. I have tested my PHP code on both Mac's & PC's and on several browsers (Firefox, Safari, IE etc etc), with several operating systems. Everything works fine, except ... On a couple of Windows XP SP2 PC's session variables in IE6 seem from time to time to get 'lost'.
3
6922
by: TCook | last post by:
I am losing my session variables after a Response.Redirect. My web.config file contains the following: <sessionState mode="InProc" stateConnectionString="tcipip=127.0.0.1:42424" cookieless="false" timeout="60" />
0
8611
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8969
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8811
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5822
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2981
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.