473,385 Members | 1,331 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.

$_SESSION getting lost

nathj
938 Expert 512MB
Hi,

I am having a spot of bother with the use of $_SESSION. They are gernally working absolutely fine with one exception.

On my form I have a capthca security image, when this image is built is stores the value in a $_SESSION variable. When the user types the security code into the box the onchange event calls my javascript function. This in turn calls a PHP page. It's an AJAX thing which is also generally working fine.

The trouble is that I want to check what the user has entered against what is stored in the $_SESSION and the $_SESSION is empty at this point in the process.

Every PHP page involved has session_start(); at the very top of it.

Does anyone have any idea where the $_SESSION is going? The aim of this is to be able to validate the security image in the same way as the rest of the form - client side using AJAX before submission when the data will be checked again and a checksum will be used.

The form, and indeed the whole site, is still in development but can viewed if that helps.

Any details entered in the form will not be stored anywhere. I haven't got to that part yet.

Many thanks
nathj
Jul 20 '07 #1
9 1800
nathj
938 Expert 512MB
Hi,

Further to my last post, which I left for the sake of completeness, I have decided not to use the captcha image on my application.registration form.

Basically, I discovered that the $_SESSION variable was one item behind when it was visible as well as not being visible where I needed it. All most peculiar.

Any way, the form is over three pages and has client and server side validation plus ther eis a final step of anual applicant approval due to the very specific target audience and the potential sensitivity of topics discussed.

However, I will be usin the Captcha idea when users post reviews, discussion topics and bolgs. So that content cannot be added by a bot.

I know this is a very brief description of what is going on but I would appreciate any feedback or advice in light of this descision.

Many thanks
nathj
Jul 20 '07 #2
Can you post up some code to show what you tried for the captcha thing? I made one for the first time the other day and it seemed to work, I'll dig it out and stick it up if you like?

I don't know if this is true because I haven't tested it fully yet, but I have a suspicion that if you have a $_SESSION['variable'] and a normal $variable with the same name then the $_SESSION one over rides the other one.
Jul 20 '07 #3
pbmods
5,821 Expert 4TB
I don't know if this is true because I haven't tested it fully yet, but I have a suspicion that if you have a $_SESSION['variable'] and a normal $variable with the same name then the $_SESSION one over rides the other one.
This occurs when register_globals is turned on.
Jul 21 '07 #4
nathj
938 Expert 512MB
Thanks for all the help, I'll double check the register globals thing when I get beack to work on Monday.

As for the code, I have now removed the captcha image from the form. As the application process involves a stage of manual approval it's not that vital.

The trouble was that I was using AJAX to validate the form. I don't want users to submit the form before it is completely valid.

I did some further tests with the code and discovered that the $_SESSION variable was storing the previuos value so if I kept refreshing the page the $_SESSION was always one step behind. It was all very peculiar.

Many thanks
nathj
Jul 21 '07 #5
Thanks pbmods! That's useful to know.
Jul 21 '07 #6
pbmods
5,821 Expert 4TB
We aim to please.
Jul 21 '07 #7
kovik
1,044 Expert 1GB
Thanks for all the help, I'll double check the register globals thing when I get beack to work on Monday.

As for the code, I have now removed the captcha image from the form. As the application process involves a stage of manual approval it's not that vital.

The trouble was that I was using AJAX to validate the form. I don't want users to submit the form before it is completely valid.
You should validate prior to submission as well, because it is possible to bypass client-side validation. Very much so.

I did some further tests with the code and discovered that the $_SESSION variable was storing the previuos value so if I kept refreshing the page the $_SESSION was always one step behind. It was all very peculiar.
That's likely due to you storing the session variable too late in your script.
Jul 21 '07 #8
nathj
938 Expert 512MB
Thanks for all the help and pointers.

I have managed to get this to work. It turns out that the $_SESSION variable was being set to early in the code that generates the captcha image.

I moved this to as soon as the code is created and hey presto it all works lovely.

Thanks to everyone for all your help. I really appreciate it.

Cheers
nathj
Jul 23 '07 #9
pbmods
5,821 Expert 4TB
Heya, nathj.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Jul 23 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
15
by: mammothman42 | last post by:
hi i've got a basic user register form, action="POST". in my php code (on the same page, i store the $_POST stuff to a $_SESSION if the user screws a field up so they don't have to reenter all...
13
by: Mimi | last post by:
Hello, I am having trouble using the session vars in PHP 4.3.9 OS: Win XP Prof Web Server IIS (is local and there are no links to other servers from the web pages I work on) Browser: IE 6.0 ...
12
by: deko | last post by:
I have a login script that creates a SESSION for authenticated users. But authenticated users still need access to particular directories (which contain files for download). My hosting provider...
12
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...
8
by: SpiritBreaker | last post by:
I am having problems getting the $_SESSION to set, the $_SESSION will work fine when its first gets the value, however, when I go to another page, the $_SESSION then loses its value. So if any one...
4
by: Daz | last post by:
Hi everyone. I'm just wondering if it's considered bad practice to have a class read from and write to the $_SESSION super global. I was just learning a little about object serialization, and I've...
12
by: jodleren | last post by:
Hi I did not notice. A system I have made, seems on one server to keep the $_SESSION even when the browser has been closed... How can I avoid that? WBR Sonnich
3
by: JRough | last post by:
I want to save two variables in a $_SESSION for use in another page: $_SESSION = $mark; $_SESSION = $num; then on the other page I did this to get the value: $mark =$_SESSION; $num =...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.