473,385 Members | 1,707 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,385 software developers and data experts.

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\Apache2\htdocs\admin
\includes\include.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 1606
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\Apache2\htdocs\admin
\includes\include.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_path), 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_close(). 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
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...
1
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...
14
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...
3
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....
6
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" ...
1
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...
5
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...
1
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...
10
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...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.