-1

I have 2 sets of $_SESSION data

Example $_SESSION["booknow"] and $_SESSION["booklater"]

not carrying to next page

single set of $_SESSION worked earlier

session_start() already on header

Any help is appreciated, Thanks

 $_SESSION = $_POST;


 $_SESSION["booknow"]["cname"] = $_SESSION["cname"];
 $_SESSION["booknow"]["cphone"] = $_SESSION["cphone"];
 $_SESSION["booknow"]["cemailid"] = $_SESSION["cemailid"];

 // return-trip fare & tips ///////////////////////////

 if(isset($_POST["raddr"])){


     $_SESSION["booklater"]["cname"] = $_SESSION["cname"];
     $_SESSION["booklater"]["cphone"] = $_SESSION["cphone"];
     $_SESSION["booklater"]["cemailid"] = $_SESSION["cemailid"];

 }

GOOOOOT IT GUYS, THANKS. we are all stupids at times. I WAS NO DIFFERENT. THANKS AGAIN. we are ALL awesome

BGB76
  • 1
  • 2
  • what does `var_dump` of the session show? maybe the array_keys are slightly different in naming – Confidence Mar 24 '17 at 14:36
  • Can you show some code so that we can reproduce? – Matt Mar 24 '17 at 14:36
  • var_dump is empty – BGB76 Mar 24 '17 at 14:36
  • Note that `session_start()` has to be on top in the file below opening the PHP tag ` – node_modules Mar 24 '17 at 14:38
  • [code]$_SESSION = $_POST; $_SESSION["booknow"]["cname"] = $_SESSION["cname"]; $_SESSION["booknow"]["cphone"] = $_SESSION["cphone"]; $_SESSION["booknow"]["cemailid"] = $_SESSION["cemailid"]; // return-trip fare & tips /////////////////////////// if(isset($_POST["raddr"])){ $_SESSION["booklater"]["cname"] = $_SESSION["cname"]; $_SESSION["booklater"]["cphone"] = $_SESSION["cphone"]; $_SESSION["booklater"]["cemailid"] = $_SESSION["cemailid"]; }[code] @mkaatman – BGB76 Mar 24 '17 at 14:41
  • `$_POST` is empty on the next page and you are mindlessly setting the entire `$_SESSION` to equal it. – MonkeyZeus Mar 24 '17 at 14:42
  • @MonkeyZeus, Yes, $_POST data is all set on FORM page. It is working fine on the same page. When posted It works ONLY with $_SESSION working fine. but not carrying data of $_SESSION["booknow"] and $_SESSION["booklater"]. Please note : only when I try with 2 set of session data not forwarding to next page – BGB76 Mar 24 '17 at 14:47
  • @BGB76 Didn't vote, why'd you assuming it was me? And also edit these codes in your question, not in the comment section, it looks really messy. – node_modules Mar 24 '17 at 14:53
  • HI @C0dekid, sorry about the remark. I have updated code. Thanks – BGB76 Mar 24 '17 at 15:00
  • please edit your current question with your code from comments. and format it as code. this makes your question more complete. – muescha Mar 24 '17 at 15:00
  • @BGB76 your question show up the review queue http://stackoverflow.com/review and receive attention from reviewers. downvote don't mark your problem lower but mark the quality of your question as lower – muescha Mar 24 '17 at 15:02
  • 1
    Welcome to Stack Overflow! You can [take the tour](http://stackoverflow.com/tour) first and learn [How to Ask a good question](http://stackoverflow.com/help/how-to-ask) and create a [Minimal, Complete, and Verifiable](http://stackoverflow.com/help/mcve) example (best would be a Playground code snippet). Add Screenshots if necessary. And please add the important error message. please add code and error messages as text and not as images. format your source code if you mark all your code and tap on the `{}` button. That makes it easier for us to help you. – muescha Mar 24 '17 at 15:03
  • 1
    don'f forget to put each answer from your comments to your question. then it becomes better visible for the reader (instead scrolling through all comments) – muescha Mar 24 '17 at 15:04

2 Answers2

0

Make sure you redirect to the same domain. So redirecting from a www.yourdomain.com to yourdomain.com doesn't carry the session forward.

Željko Krnjić
  • 2,356
  • 2
  • 17
  • 24
0

This is a commonly asked question. Without knowing any near details, I would recommend you to compare your code with the following post:

Session Variables Not Carrying Over to Other Pages

Community
  • 1
  • 1
Odd
  • 563
  • 8
  • 20
  • bro, life of code junkie is always not same like coach potato. years of coding, but there comes time to pulling hair & go bald. Then we ask question to see if any answer comes up. This is was fine until I tried something new to simplify post data with 2 set of $_SESSION variables that can carry data across 4 pages. I tried. NO RESULT. Any help is APPRECIATED. – BGB76 Mar 24 '17 at 15:12