473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session Problem - could it be cos of register_global s?

Hi,

!!I'm A Newbie Alert!!

My server runs PHP version 4.4.3.

I'm successfully creating a session and can set and retrieve my own
session variables.

As far as I can tell the $_SESSION['uid'] variable should be created
automatically when session_start() is called. When I retrieve this
variable however it is empty.

Is this because -- manual -- "PHP directive register_global s went from ON
to OFF in PHP » 4.2.0." ??

If so: How do I turn register_global s on, do I just edit the .htaccess
file and add the line below (exactly as shown?

php_flag register_global s on

If not, any ideas why $_SESSION['uid'] does not have a value?

Note the value of $_SESSION['cookie'] is also empty, isn't that also
supposed to be created and sent to the browser automatically by
session_start() ?? --My browser does not receive a cookie either?

In a muddle, regards, etc..
Nov 19 '07 #1
5 6108
On Mon, 19 Nov 2007 20:25:25 +0100, Matthew <ma*****@spamki ller.comwrote:
My server runs PHP version 4.4.3.

I'm successfully creating a session and can set and retrieve my own
session variables.
OK
As far as I can tell the $_SESSION['uid'] variable should be created
automatically when session_start() is called. When I retrieve this
variable however it is empty.
Nope. Unless you name it that way.
<http://nl2.php.net/manual/en/ref.session.php >

The default 'session.name' is PHPSESSID, which you can normally will NOT
find in $_SESSION, but in one of the $_REQUEST arrays (and thus obviously
in $_REQUEST). $_COOKIE['PHPSESSID'] _if_ the session works with cookies,
optionally in the $_POST or $_GET array in case of a transparant session
id (which is not recommandable).

If you choose another name for a session, this should be done with
session_name('c ustom_name_of_s ession') BEFORE the call to session_start() :
<http://nl2.php.net/manual/en/function.sessio n-name.php>
--
Rik Wasmus
Nov 19 '07 #2
On Mon, 19 Nov 2007 20:38:05 +0100, Rik Wasmus
<lu************ @hotmail.comwro te:
On Mon, 19 Nov 2007 20:25:25 +0100, Matthew <ma*****@spamki ller.com>
wrote:
>My server runs PHP version 4.4.3.

I'm successfully creating a session and can set and retrieve my own
session variables.

OK
>As far as I can tell the $_SESSION['uid'] variable should be created
automaticall y when session_start() is called. When I retrieve this
variable however it is empty.

Nope. Unless you name it that way.
<http://nl2.php.net/manual/en/ref.session.php >

The default 'session.name' is PHPSESSID, which you can normally will NOT
find in $_SESSION, but in one of the $_REQUEST arrays (and thus
obviously in $_REQUEST). $_COOKIE['PHPSESSID'] _if_ the session works
with cookies, optionally in the $_POST or $_GET array in case of a
transparant session id (which is not recommandable).

If you choose another name for a session, this should be done with
session_name('c ustom_name_of_s ession') BEFORE the call to
session_start() :
<http://nl2.php.net/manual/en/function.sessio n-name.php>
Addendum: if you're just curious what your session id actually is, use
session_id().
--
Rik Wasmus
Nov 19 '07 #3
Rik Wasmus emailed this:
On Mon, 19 Nov 2007 20:38:05 +0100, Rik Wasmus
<lu************ @hotmail.comwro te:
>On Mon, 19 Nov 2007 20:25:25 +0100, Matthew <ma*****@spamki ller.com>
wrote:
>>My server runs PHP version 4.4.3.

I'm successfully creating a session and can set and retrieve my own
session variables.

OK
>>As far as I can tell the $_SESSION['uid'] variable should be created
automatical ly when session_start() is called. When I retrieve this
variable however it is empty.

Nope. Unless you name it that way.
<http://nl2.php.net/manual/en/ref.session.php >

The default 'session.name' is PHPSESSID, which you can normally will
NOT find in $_SESSION, but in one of the $_REQUEST arrays (and thus
obviously in $_REQUEST). $_COOKIE['PHPSESSID'] _if_ the session works
with cookies, optionally in the $_POST or $_GET array in case of a
transparant session id (which is not recommandable).

If you choose another name for a session, this should be done with
session_name(' custom_name_of_ session') BEFORE the call to
session_start( ):
<http://nl2.php.net/manual/en/function.sessio n-name.php>
Thanks for both replies Rik.
Addendum: if you're just curious what your session id actually is, use
session_id().
What about the cookie, how do I retrieve that, I need to add it to a
database table?

Cheers and sorry for the newbie questions.
Nov 19 '07 #4
On Mon, 19 Nov 2007 20:49:23 +0100, Matthew <ma*****@spamki ller.comwrote:
Rik Wasmus emailed this:
I thought I posted :P
>On Mon, 19 Nov 2007 20:38:05 +0100, Rik Wasmus
<lu*********** *@hotmail.comwr ote:
>>On Mon, 19 Nov 2007 20:25:25 +0100, Matthew <ma*****@spamki ller.com>
wrote:
As far as I can tell the $_SESSION['uid'] variable should be created
automaticall y when session_start() is called. When I retrieve this
variable however it is empty.

Nope. Unless you name it that way.
<http://nl2.php.net/manual/en/ref.session.php >

The default 'session.name' is PHPSESSID, which you can normally will
NOT find in $_SESSION, but in one of the $_REQUEST arrays (and thus
obviously in $_REQUEST). $_COOKIE['PHPSESSID'] _if_ the session works
with cookies, optionally in the $_POST or $_GET array in case of a
transparant session id (which is not recommandable).

If you choose another name for a session, this should be done with
session_name( 'custom_name_of _session') BEFORE the call to
session_start ():
<http://nl2.php.net/manual/en/function.sessio n-name.php>

Thanks for both replies Rik.
Addendum: if you're just curious what your session id actually is, use
session_id().

What about the cookie, how do I retrieve that, I need to add it to a
database table?
Trust me, you don't. The value in $_COOKIE['PHPSESSID'] is exactly the one
given to you by session_id(). (Assuming you have the default PHPSESSID
session name)
--
Rik Wasmus
Nov 19 '07 #5
Rik Wasmus emailed this:
On Mon, 19 Nov 2007 20:49:23 +0100, Matthew <ma*****@spamki ller.comwrote:
>Rik Wasmus emailed this:

I thought I posted :P
>>On Mon, 19 Nov 2007 20:38:05 +0100, Rik Wasmus
<lu********** **@hotmail.comw rote:
On Mon, 19 Nov 2007 20:25:25 +0100, Matthew <ma*****@spamki ller.com>
wrote:
As far as I can tell the $_SESSION['uid'] variable should be
created automatically when session_start() is called. When I
retrieve this variable however it is empty.

Nope. Unless you name it that way.
<http://nl2.php.net/manual/en/ref.session.php >

The default 'session.name' is PHPSESSID, which you can normally will
NOT find in $_SESSION, but in one of the $_REQUEST arrays (and thus
obviously in $_REQUEST). $_COOKIE['PHPSESSID'] _if_ the session
works with cookies, optionally in the $_POST or $_GET array in case
of a transparant session id (which is not recommandable).

If you choose another name for a session, this should be done with
session_name ('custom_name_o f_session') BEFORE the call to
session_star t():
<http://nl2.php.net/manual/en/function.sessio n-name.php>

Thanks for both replies Rik.
> Addendum: if you're just curious what your session id actually is, use
session_id().

What about the cookie, how do I retrieve that, I need to add it to a
database table?

Trust me, you don't. The value in $_COOKIE['PHPSESSID'] is exactly the
one given to you by session_id(). (Assuming you have the default
PHPSESSID session name)
Okay, thanks again. Hopefully I'll get to grips with all this tomorrow.
It's 22.00 in my TZ and I'm ready for a beer (or 2) before bed. Night and
thanks for the help.
Nov 19 '07 #6

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

Similar topics

1
3942
by: Chip | last post by:
I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the login button is pushed (or the enter key pressed) the login screen redraws, never loading the next page. I don't get any error messages. I am using FreeBSD-5.1/Apache-2.0.46/MySQL-4.1.0.1/PHP-4.4.3.4 Thanks, Chip I have pasted the code below -
2
3309
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals and a couple "better pratice" code. Not perfect, but better. Problem : I'm testing everything with Firefox on my machine (IIS on WinXP Pro), and everything is ok. As soon as I try MS IE 6, it doesn't seem to keep the sessions from page to...
7
1428
by: Name | last post by:
To those that can save me from myself: I have a site that has been working perfectly for a few years now, under PHP 4.2.3. Since later versions of PHP run so much more quickly, I wanted to update this site to one of those later versions. Being a very cautious person, I started with 4.3.11, since it was the highest version of the next PHP increment. When I tried this version, my session file kept getting rebuilt (with the same name) as...
7
2039
by: Nicole | last post by:
Hi I'm trying to use a function to set a session variable. I have three files: The first file has: <?php session_start(); // This connects to the existing session ?> <html> <head>
35
2035
by: Steve JORDI | last post by:
Hi, I'm trying to implement a singleton in PHP4 but it doesn't seem to work. The object is recreated each time I call it. The goal of the class is to keep a variable up to date. It's used to display a database content, 25 rows at a time. The singleton keeps track of the current starting row and increases it or decreases it by 25 depending on the user action (pressing a Next or Prev button). Those buttons are submit buttons calling the...
5
1604
by: Baeribeeri | last post by:
I am writing a foto upload site. A PHP page displays the uploades fotos an the customer can choose several things. The data of the fotos are kept in an array called bilder. I keep the data in a session. When the customer send the data the following code will be run: if (isset($sendorder_x)) { session_start(); $nachricht = $bemerkungen; session_register(nachricht);
34
5607
by: Kurda Yon | last post by:
Hi, As you have recommended I did not use the session_register(). In one file I have executed such line: $_session = 2.0; Then, in another file, I have executed the following line: $ex = 3.0. And than I have noticed that the previous assignment is seen
10
26074
by: Kurda Yon | last post by:
Hi, I set the register_globals off and try to get my code working under the new conditions. I stuck on the following problem: Warning: Unknown(): Your script possibly relies on a session side- effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting...
8
1774
by: sheldonlg | last post by:
I have a case where the session values appear to lose their value. I tracked it down with some print_r inserted. Here are the lines: print '<br 1: '; print_r($_SESSION); $adminLevel = $_POST; print '<br 2: '; print_r($_SESSION); Here is the output: 1: Array ( =SUPERUSER =0 )
0
9656
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
9498
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
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
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
10118
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
8995
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
6750
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
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.