473,786 Members | 2,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with retrieving session variables

Hi Guys,

I am using sessions to store the login name and then retrieve it on
every page. Here are the details of the php settings.

1) I have PHP 4.2.2 installed on a Apache 1.3.27 server.
2) I have register_global s off.
3) I use $_session['loginname']= $loginname to store the loginname
into the session and then retrieve it on other pages using a
$HTTP_SESSION_V ARS['loginname'].

My problem is that sometimes, I am able to retrieve the loginname from
the session and sometimes I am not. When I am not able to get the
loginname, I refresh the page 3-4 times and the loginname shows up.
This happens on every page. Am I screwing up somewhere? Does this
depened on the speed of the server?

Thanks for your help.
Jul 17 '05 #1
1 4615
Avinash Korwarkar wrote:
Hi Guys,

I am using sessions to store the login name and then retrieve it on
every page. Here are the details of the php settings.

1) I have PHP 4.2.2 installed on a Apache 1.3.27 server.
2) I have register_global s off.
3) I use $_session['loginname']= $loginname to store the loginname
into the session and then retrieve it on other pages using a
$HTTP_SESSION_V ARS['loginname'].

My problem is that sometimes, I am able to retrieve the loginname from
the session and sometimes I am not. When I am not able to get the
loginname, I refresh the page 3-4 times and the loginname shows up.
This happens on every page. Am I screwing up somewhere? Does this
depened on the speed of the server?


Hi Avinash,

No, not the speed of the server.

Check the following:
1) Do you ALWAYS start your php-scripts with session_start() ??
Or
Alternatively: did you put session.auto_st art = 1 in your php.ini file?\

2) Be sure you did not produce any output before the first session-calls.

3) To debug, check the coockies in your webbrowser. Delete them, log in
again, check what is set, etc.etc. You can also check the real content of a
session by finding the right one in the temp-directory as set in php.ini
(On my system: session.save_pa th = /tmp)

4) Last but not least: I had trouble with PHP-sessions too under 4.2 that
was soo darn vague and difficult to replicate, I got a real headage of it.
I upgraded to php4.3, problems gone....
(I could only find some scattered remarks on this, not a lot.)

Good luck,
Regrads,
Erwin Moller
Jul 17 '05 #2

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

Similar topics

9
4964
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
2
1839
by: Alex Hopson | last post by:
Hi, I'm trying to modify a shopping cart script from Mastering PHP/MySQL and am having trouble setting up some arrays for it. The original code, below, stores the cart items in a session variable array ($HTTP_SESSION_VARS = array();) basically this stores an associative array with the id number of the product and the qty (ie cart = qty of that product). This works fine, but I need to be able to have sub options AND colours for
1
2449
by: Sean Pinto | last post by:
Ok, you all are going to have to bear with me on this one as it is kinda complicated to explain. I am implementing a company management suite that requires Role-Based authentiations (ie. users are in groups and groups have roles). I have one script which is included in EVERY page in the protected area (masterFuncs.php) and it contains function declarations as well as the authentication module kick-off. Here is a snippet from masterFuncs...
9
2386
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use - perhaps I'm just not very smart or perhaps MS is making this too hard for us sql bunnies to understand - I dunno, but I'd really appreciate someone explaining what I'm doing wrong here & perhaps suggest a better approach.. I'm familiar with use of...
2
2393
by: Boban Dragojlovic | last post by:
I'm building a complex web-based reservations system. Gathering the user's data requires between 8 and 15 pages (depending on which options they are interested in). I use the "Session" object to store the various elements as the user moves through the pages. Rather than storing the preferences directly in the Session object (e.g. Session("LastName") = ...), I created a class <Serializable()> Public Class ReservationInfo
2
2257
by: Glenn Venzke | last post by:
I'm trying to put together a web form that lists all current session information. The session info is stored in SQL server database (ASPState) and I'm trying to retreive and display using a SQLDataReader. I seem to have no trouble querying the "ASPStateTempSessions" table but when I try to write it to the page, I throw an exception that basically says that there is no data to display. Is there some special method you must use when performing...
1
1232
by: tperri | last post by:
Hi everyone, I have an .aspx file that is used by an external program to perform a function. There is no code behind, all code and HTML is contained in one file. the structure is like this: <% string strBlah = Request.Querystring("jdkfsd"); string userid = Convert.ToString(HttpContext.Current.Session);
14
2382
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and User B has access to 5, now when both of us hits to the server at the same time then their session variables gets mixedup means either User A and USer B will have now 5 companies or both have 10 companies. Now again when User A hits to the server...
0
1185
by: Laurahn | last post by:
Hi: i'm using modal window (showmodelessdialog) on asp. when the object is created i used session variables. After the object is closed the data is remaining on the modal window when is open again, even if i clear all session variables. i call the modal windows as: Response.write("<script>window.showModelessDialog('myPage.aspx','window', 'center:Yes;help:No;status:false;dialogWidth:740px;dialogHeight:395px')</script>")
0
9650
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
9497
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,...
1
10110
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
9962
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
8992
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
6748
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
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.