473,412 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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_register
("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 15408
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.com> wrote in message
news:39*************@individual.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_register
("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_register - see warning about
register_globals 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_close()
beforehand, as in:

session_write_close();
header('Location: 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.com> wrote in message
news:39*************@individual.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
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
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...
1
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...
2
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....
0
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...
2
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. ...
2
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...
3
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??...
2
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...
2
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...
3
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"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.