473,800 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why are session variables not working for me??

Hi,

I am trying to register session variables in the following way:

$_SESSION['myname'] = 'Burnsy';

When i set them and then output the following on the same script:

echo $_SESSION['myname']

... it works, but when I navigate to a different page from the one that
sets the variables it doesnt remember them and I get an error message:

Notice: Undefined index: myname in C:\webserver\Ap ache2\htdocs\ad min
\includes\inclu de.AuthProcess. php on line 20

I have DEFINETELY remembered to use session_start() at the very start
of my scripts. I am setting the variables inside a class but Im
echo'ing then from the running script .. should this matter? Do I need
to do anything in php.ini or something like that? Is it maybe using
cookies for sessions? If so, I dont know a great deal about this ..
please briefly explian what I should do. Any help would be much
appreciated. Thanks

Burnsy
Dec 19 '07 #1
1 1624
On Wed, 19 Dec 2007 12:06:14 +0100, bizt <bi******@yahoo .co.ukwrote:
Hi,

I am trying to register session variables in the following way:

$_SESSION['myname'] = 'Burnsy';

When i set them and then output the following on the same script:

echo $_SESSION['myname']

.. it works, but when I navigate to a different page from the one that
sets the variables it doesnt remember them and I get an error message:

Notice: Undefined index: myname in C:\webserver\Ap ache2\htdocs\ad min
\includes\inclu de.AuthProcess. php on line 20

I have DEFINETELY remembered to use session_start() at the very start
of my scripts.
Of all scripts using a sessions offcourse, not just the one setting the
variables.
I am setting the variables inside a class but Im
echo'ing then from the running script .. should this matter?
Nope, $_SESSION is a superglobal, so that should work
Do I need
to do anything in php.ini or something like that? Is it maybe using
cookies for sessions?
By default, yes. With a transparent session id it can also be propagated
as a POST or GET value (see the manual:
<http://www.php.net/manual/en/ref.session.php >
If so, I dont know a great deal about this ..
please briefly explian what I should do. Any help would be much
appreciated.
First check wether or not your session is actually carrier over. echo
session_id(), and check wether it remains the same. If it isn't, your
browser probably ignores the cookie. If it is, something is overwriting
your session. If you use the default session handler (files), check where
these files are stored (session.save_p ath), and wether the session files
are created/filled.

In rare cases (concurrent requests/long processing time) it can be
advisable to do all your session work early on and call
session_write_c lose(). Normally there is no need though.
--
Rik Wasmus
Dec 19 '07 #2

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

Similar topics

9
3337
by: Larry Woods | last post by:
I have a site that works fine for days, then suddenly, I start getting ASP 0115 errors with an indication that session variables IN SEPARATE SESSIONS have disappeared! First, for background information, I have a customized 500-100 page that sends the value of various session variables via email to my support site. The situation: On the home page of the site, the FIRST THING that is done is a Session
1
3114
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a "security update" installed on the server a few days ago but I can't find out exactly what it was. In the research I have done I found many articles on the subject of session variables in ASP pages inside framesets. From what I read a new...
14
3242
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you go to is a login form, which will set several session variables with the name used to log in, appropriate security level and some other misc variables, and then will go to a main menu for each particular security level using Server.Transfer. ...
3
2638
by: Rob | last post by:
I'm trying to use session variables to store datasets when moving from page to page (and returning). The datasets are small (I know some may comment on performance issues). It seems simple to use. I can pass a dataset to the second page (once I get one additional page working, the rest will be simple) successfully but am not able to return to the default page and retrieve the dataset and rebind it to my datagrid. Once I store it as a...
6
2566
by: Nedu N | last post by:
Hi, I am trying to design a Home page for my applicatiion in which i want show the links for for some itms... I tried to put the following <td> <font face="Arial, Helvetica, sans-serif" color="#ffffff" size="2"> Contact | My Profile | Logout /font> </td>
1
1800
by: yoshibebe | last post by:
Hi, I have developed a project on my local machine. The session state variables are working fine on my local machine. When I port it into a another server called v-projects, and I try to run the project from that other server, the session state variables are being set randomly. For example, in the following code: SetSelectionSessionState();...
5
548
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know users or save any data. If the application crashes or user exits the program they should simply start again. Pretty basic. All interactions are stored in an array (not much going on to save to a
1
1548
by: Shahar Nechmad | last post by:
I'm using ASP.NEt 2.0. I use the session to save important information about the user current session (for example the current project he is working on). I use those variables in almost every web page in the application. When a user session times out, I want to be able to make the user to relogin and continue working with the application. 1. Is there easy way to catch an even just before the session times out? Or to prelong a session (so...
10
1990
by: isynclere | last post by:
Hi all, I am stuck with a very strange session prob. Developing on locahost. Have just gone back to a project I was working on to check all is ok and the login function is no longer working properly, basically the session variables arent being carried over pages, except, and this is strange, in safari. When i echo the session variables on other pages they show in safari, but not in firefox, ie, or opera. So login works in one browser...
6
3785
by: ChrisAtWokingham | last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart editing processes place a very heavy load on the server as the effects of the edit ripple through the organisation structure, requiring potentially large numbers of rows in one of the tables to be updated. (I have done it this way to make the more...
0
9691
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
9551
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
10279
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...
0
9092
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
6815
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
5473
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
4150
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
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.