Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Mohibur Rashid 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

In php you start a session using:
PHP
SESSION_START();

To store a variable you use:
PHP
$_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:
PHP
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
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900