Click here to Skip to main content
11,795,848 members (78,768 online)
Rate this: bad
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 ?

Posted 12-May-12 7:22am
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
Please Sign up or sign in to vote.

Solution 1

In php you start a session using:
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:
Make sure not to terminate the session until your done reading the data because when you terminate the session it wipes the values.


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

  Print Answers RSS
0 Maciej Los 410
1 Abhinav S 368
2 OriginalGriff 300
3 Sergey Alexandrovich Kryukov 266
4 KrunalRohit 249
0 OriginalGriff 1,852
1 Maciej Los 1,465
2 KrunalRohit 1,300
3 CPallini 840
4 Richard MacCutchan 828

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 14 May 2012
Copyright © CodeProject, 1999-2015
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