473,659 Members | 2,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_SESSION does not work to me...

Hi,

Another newbie question.

I'm using to do a test

$_SESSION["count"]++;

after a POST action, but evry time the page is reloaded $_SESSION is never
initialized... why?

Thanks
Aug 26 '07 #1
3 2610
On Aug 26, 5:25 pm, "Fabio" <znt.fa...@virg ilio.itwrote:
Hi,

Another newbie question.

I'm using to do a test

$_SESSION["count"]++;

after a POST action, but evry time the page is reloaded $_SESSION is never
initialized... why?

Thanks
Do you have session_start() at the beginning of your page?

Aug 26 '07 #2
"ZeldorBlat " <ze********@gma il.comha scritto nel messaggio
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
>
Do you have session_start() at the beginning of your page?
mmm... you're right, thanks.
But I read somewhere that with $_SESSION it was useless to call
session_start() and others session functions... :(

session_start() never reset the $_SESSION, right?
I have to call it at evry page POST or I have to check if session was
already started and only if not I will call session_start() ?

Thanks again ;)
Aug 26 '07 #3
On Aug 26, 6:42 pm, "Fabio" <znt.fa...@virg ilio.itwrote:
"ZeldorBlat " <zeldorb...@gma il.comha scritto nel messaggionews:1 1************** ********@k79g20 00hse.googlegro ups.com...
Do you have session_start() at the beginning of your page?

mmm... you're right, thanks.
But I read somewhere that with $_SESSION it was useless to call
session_start() and others session functions... :(
You're thinking of session_registe r()
>
session_start() never reset the $_SESSION, right?
I have to call it at evry page POST or I have to check if session was
already started and only if not I will call session_start() ?
Just call session_start() the top of every page. Otherwise the
session variables will not be available. If you do it once at the top
of the page you don't need to check if it's started every time you
want to access a session variable. Of course you could also enable
session.auto_st art in php.ini -- but I wouldn't recommend that for a
variety of reasons.

Aug 26 '07 #4

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

Similar topics

0
2590
by: Thomas Carcaud | last post by:
I read php manual many times but I can't figure out register_globals works. I m using Php 4.3.2 and register_globals on. It seems to have different effects on $_GET and $_SESSION. First with $_GET : <? echo $var."\n"; echo $_GET."\n"; $var="gna"; echo $var."\n"; echo $_GET."\n"; $_GET="gnou";
2
16274
by: Håvard Olerud Eriksen | last post by:
I've been working on a webshop, and I've got most of the functionality up and running. One problem, however, that I don't seem to be able to solve is as follows. My shopping cart is stored in $_SESSION array. As I need to keep tabs on what items are ordered and their quantity I add elements like this: array_push($_SESSION,array($item => $quantity)); If I add three elements and then var_dump the global variable it spits out: array(3) { =>...
5
2972
by: Ken | last post by:
What am I doing wrong? I set the variable co_name on the first page with an <input.... > and session_start() at the top of both pages. Clicking on a link that takes me to the second page: Script on the second page. echo $_SESSION; Does not display
2
1636
by: Svend Andreas Horgen | last post by:
I used to believe I fully understood sessions... Apparently PHP does not handles numeric indexes in $_SESSION, as far as I can see. The same yields for both PHP 4 and 5. Suggestions or explanations to the following? I thought $_SESSION was a super global array, but arrays would for sure allow for numeric indices, right? As an example, this works: $id = "number" . 3; $_SESSSION++;
3
14903
by: Phil Powell | last post by:
PHP: unset($_SESSION); In my original environment (PHP 4.3.2) this line will delete the session variable 'mainDisplay'. But in the testing environment (PHP 4.3.6) the variable persists even after unset() is called. Is there some special setting in PHP that can allow a session to
4
1936
by: comp.lang.php | last post by:
This is an urgent request (as always) generate_admin_customer_position_dropdown($customerResult, $customerResult->id); print_r($_SESSION); This code will generate an HTML dropdown as well as set a $_SESSION
21
3053
by: axlq | last post by:
Someone please tell me if I've discovered a PHP bug. I'm sitting in front of several computers on my home network, behind a NAT firewall/router. I am testing my web site on these different computers (running different browsers, logged in as different users, etc.). My web site keeps track of users logged in through the use of $_SESSION. Here's the bizarre thing: All computers are logged off, then I log into my web site with one...
12
41158
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if someone here can enlighten me as to why the problematic code is having the effect it is. For reasons I don't know, if the PHP version is 5 or greater, register_long_arrays is false and $_SESSION exists, the following statement is executed: ...
15
5945
by: Evil Otto | last post by:
My page loads, and calls an init() function that returns content to a div on the page, as well as setting a $_SESSION variable. The content it returns includes a link that calls the same variable, but I get an error that says the index isn't defined. The second two calls are AJAX-generated. The second call immediately echos the $_SESSION variable back after it sets it, and it sets it properly. But the subsequent request doesn't see...
4
2047
by: Pseudonyme | last post by:
Dear Sirs and Madams, Receive as information that storing a MYSQL result under $_SESSION was accelerating web page displays processes ? Absolutly needed but impossible to get this working ! I try, but do not succeed in implement $_SESSION with MYSQL. <?php session_start();
0
8747
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
8528
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
7356
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
5649
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
4175
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...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
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
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
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.