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

session variable values are lost when redirecting

I have created a php script for login using session variables in php . After checking the login information , I redirected to another page using following scripts
Expand|Select|Wrap|Line Numbers
  1.           $username="valid";
  2.     session_start();
  3.     session_register("username"); 
  4.            echo "<script>";
  5.            echo " self.location='loginvendor.php' "; 
  6.            echo "</script>";
  7.  
  8. In target page ,  value of session variable was lost. I have used following  code in target page(loginvendor.php)
  9.  
  10. if(strlen($_SESSION["username"])<=0)
  11. {
  12. header( "Location:  index.php" );   
  13. }
  14.  
  15.  
Due to this session variable problem , I was redirected to index.php in every time.

I do not know how to correct above error. Plz help
Aug 20 '07 #1
3 1906
ronnil
134 Expert 100+
hi benoypaul

session_register is a deprecated function and will not work when register_globals is off (which is propably is). Use $_SESSION when setting your session var. this should work.

for more info see http://www.php.net/manual/en/functio...n-register.php
Aug 20 '07 #2
pbmods
5,821 Expert 4TB
Heya, benoypaul.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Aug 20 '07 #3
the logic behind the login is quite simple. first collect the login details(username and password)
secondly only start a session on successful authentication of the user. now create session variable to hold whatever data u want to have access to on other pages.

after u must have done all these all u have to do is start a session on the redirect page if one is not already started and reference the session variables.
Aug 21 '07 #4

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

Similar topics

3
by: William | last post by:
Hi I have an ASP.NET application that connects to an Access database. Everything works fine except for the Session object. Data in the session object is lost after I've made a call to the...
14
by: Venkat Chellam | last post by:
I have a peculiar problem. I have a simple web application which loads some data from the oracle table and display in the datagrid in the webpage and datagrid has page enabled which shows 10 rows...
9
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings...
14
by: Coleen | last post by:
Hi All :-) We have an APSX application using VB.net as the code behind, which uses one or two session variables per page. These Session variables are passed to the final page and calculations...
1
by: Vidyadhar Joshi | last post by:
I have the following scenario in a true load balanced environment (without sticky sessions): There are 2 ASPX pages. I want to pass an object from the first page to the second page. On the...
3
by: samik | last post by:
I have working on WinXP + IIS 5.0 + .NET 1.1 Whenever i open a page with the url starting as http://localhost/<page addressor http://127.0.0.1/<page addressthe application to hold session...
0
by: Aarchaic | last post by:
Hello i have problem my session variables seem to disapear as i go along i've created this code to ilustrate whats happening First off i just post 3 detials like a name a age and a favourite...
22
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users then direct them to a personalized page. This is...
13
by: SAL | last post by:
Okay, don't bash me to hard for my design on this app, it's my first web app and it's in production. My basic design is using Datatables created via the designer with a business logic class in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.