Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP session script
hi all.
 
im trying to do the following :
a simple login page, asking the user for user/pass . verify that user exist in db and then, write the username to a session varm and then .
redirect him/her to another page that acts a small business online store .
 
what happens now, is that the user can purchase an item using paypal procedure, that redirects to a quick paypal secure check out page (payment page).
 
when payment is complete, i get a notification to a listener script on my server, that captures the payment status (and some other stuff....) and then runs another procedure that write all the relevant details to my db .
 
now, what im trying to do, is use the session var 'username' i saved in the 1st stage, and add it to the data i'm writing to the db .
except, when i run that cmd in the script, the session var holds no value .
 
i guess im not that educated on sessions. can anybody here plese give me a clue ?
 
moses
Posted 12-May-12 8:22am
Comments
Mohibur Rashid at 13-May-12 8:01am
   
you must have to use session_start function in the beginning of every page. and indexes are case sensitive

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In php you start a session using:
SESSION_START();
To store a variable you use:
$_SESSION['var'] = "your value here";
To read from that variable in another page or even the same page use the same command minus the equals sign forward.
Then finally to terminate the session use:
SESSION_DESTROY();
Make sure not to terminate the session until your done reading the data because when you terminate the session it wipes the values.
 
-Jordan
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 120
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 14 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100