473,783 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

session variable values are lost when redirecting

28 New Member
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 1922
ronnil
134 Recognized Expert New Member
hi benoypaul

session_registe r is a deprecated function and will not work when register_global s 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 Recognized Expert Expert
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
fobilow
6 New Member
the logic behind the login is quite simple. first collect the login details(usernam e 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
2614
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 database. To test, I've created two test aspx pages. Test1.aspx contains two buttons. The first button sets values in the session object and then navigates to Test2.aspx. Test2.aspx only displays the values in the session object. The second button...
14
2264
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 at a page.I have a search criteria to search the records based on the data range i give This is what i have done, in the !IsPostBack section. I am setting up the oracle connection, creating dataset object, datadapter and i aslo load the data...
9
2547
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 they have "Always allow session cookies" set to true When the browser connects to the website the first page sets a session variable called "user_ref" to something and then calls another page. If on
14
2195
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 and summaries are done there. In order for all of the values to appear on the last page, the user has to view each page that has a session variable to be passed to the last page. The only way I can think of to bypass the necessity of the user...
1
3540
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 btnContinue_Click event of Page1.aspx, I create the object and store it in a session variable. The next statement would be Response.Redirect("Page2.aspx"). The code appears like this: private void btnContinue_Click(object sender, EventArgs e) {...
3
1865
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 values. Session id changes on each request. But when I try with the network ip like http://10.10.10.10/<Page address(where 10.10.10.10 is localhost itself) it works fine. session id remains same. I am using session mode as InProc in web.config and my...
0
1481
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 number. that in turn goes to the next page where its being picked up by the php code and put into the Global Variable. the page uses the variables with no problem and you can select a link to go onto the next page where the number is being...
22
14904
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 done in 3 steps: Step 1. Normal http login page. Step 2. A page called login.php that takes the posted username, stores it as $_SESSION, and registers it session_register("username"); user is taken to the personalized page according to his username...
13
3071
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 between the datatable and ObjectDataSources. In one page I had a Gridview with select enabled. When an row in the grid is selected, I retrieve the SelectedValue, store the value in a Session variable and redirect the response to another web page,...
0
9480
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
10147
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
10083
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
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
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();...
1
4044
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
3645
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.