M.O.S. Studios Posted July 7, 2010 Share Posted July 7, 2010 ok weird situation, I'm working on a members registration page. At the moment I'm working on the e-mail validation process. I'm doing this by storing the information in session data; I then send the user an email containing a url they have to goto. The url contains the session_id() so i can recall the session data. Here is where the problem starts. When I run the script it works fine until i put it in the cms. i get the email with the session_id() url, but for some reason the session always shows up as blank. any ideas? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/206996-session_id/ Share on other sites More sharing options...
M.O.S. Studios Posted July 7, 2010 Author Share Posted July 7, 2010 maybe the code will help out <?php if($_POST['submit']==BUTTMAKEACCOUNT){ if($_GET['section']=='newaccount'){ SESSION_START(); $_SESSION['newmember']['email']=$_POST['newmember_email']; $_SESSION['newmember']['password']=$_POST['newmember_password']; $_SESSION['newmember']['username']=$_POST['newmember_username']; $_SESSION['newmember']['fname']=$_POST['newmember_firstname']; $_SESSION['newmember']['lname']=$_POST['newmember_lastname']; $_SESSION['newmember']['tmp_pass']=randstr('15', TRUE, FALSE); cart_mail('New member', $_SESSION['newmember']['fname'], $_SESSION['newmember']['lname'], $_SESSION['newmember']['email'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $_SESSION['newmember']['username'], $_SESSION['newmember']['tmp_pass'], $sessionid); } } ?> <?php echo $error; ?> <form method='POST' action='index.php?page=members§ion=newaccount'> <div class='newmember'> <div class='section'><?php echo MEMBERS_LOGININFO; ?></div> <div class='email'><?php echo EMAIL; ?></div> <div class='email_input'><input name='newmember_email' value='<?php echo $_POST['newmember_email']; ?>' type='text' size='15' maxlength='25'></div> <div class='password'><?php echo PASSWORD; ?></div> <div class='password_input'><input name='newmember_password' value='<?php echo $_POST['newmember_password']; ?>'type='password' size='8' maxlength='8'></div> <div class='passwordcon'><?php echo CONPASSWORD; ?></div> <div class='passwordcon_input'><input name='newmember_conpassword' value='<?php echo $_POST['newmember_conpassword']; ?>' type='password' size='8' maxlength='8'></div> <div class='section'><?php echo MEMBERS_PROFILEINFO; ?></div> <div class='username'><?php echo MEMBERS_USER; ?></div> <div class='username_input'><input name='newmember_username' type='text' size='15' maxlength='25' value='<?php echo $_POST['newmember_username']; ?>'></div> <div class='firstname'><?php echo MEMBERS_FIRSTNAME; ?></div> <div class='firstname_input'><input name='newmember_firstname' type='text' size='15' maxlength='25' value='<?php echo $_POST['newmember_firstname']; ?>'></div> <div class='lastname'><?php echo MEMBERS_LASTNAME; ?></div> <div class='lastname_input'><input name='newmember_lastname' type='text' size='15' maxlength='25' value='<?php echo $_POST['newmember_lastname']; ?>'></div> <div class='submit'><input type='submit' name='submit' value='<?php echo BUTTMAKEACCOUNT; ?>'></div> </div> </form> i took out the form validation parts of the script because they where not needed for this example. there is a custom function called cart_mail. It sends a validation email that requires the user to click on a link to prove their email is real. if you notice the last value in the function is session_id(). that number is inserted into the url. The e-mail sell fine and it creates the url as expected. here is my next script (used just for testing use at the moment) <?php SESSION_ID($_GET['sid']); SESSION_START(); print_r($_SESSION); ?> the two scripts work perfectly one their own. how ever when inserted to my cms the 2nd script doesn't call the session data any more. Any ideas? Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1082523 Share on other sites More sharing options...
gwolgamott Posted July 7, 2010 Share Posted July 7, 2010 move session_start() to above the session_id() Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1082678 Share on other sites More sharing options...
Mchl Posted July 7, 2010 Share Posted July 7, 2010 move session_start() to above the session_id() You haven't use it before, have you? If id is specified' date=' it will replace the current session id. session_id() needs to be called [b']before[/b] session_start() for that purpose. Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1082690 Share on other sites More sharing options...
gwolgamott Posted July 7, 2010 Share Posted July 7, 2010 No I haven't. I stand corrected. I haven't had a use for Session_id... well have but just didn't know it. Hmm learn something new all the time though. I just always knew where it was stored and never looked for an alternative way of using it.... if I have to use it I know now. Thanks. Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1082701 Share on other sites More sharing options...
M.O.S. Studios Posted July 8, 2010 Author Share Posted July 8, 2010 So this is what i learned on this issue, first, the problem is in this code: <?php SESSION_ID($_GET['sid']); SESSION_START(); print_r($_SESSION); ?> as soon as I try to load any session_id into this script, it deletes all the values. Any ideas? Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1082973 Share on other sites More sharing options...
kenrbnsn Posted July 8, 2010 Share Posted July 8, 2010 What you're not showing us is the function that generates the email. That seems to be the key to the problem. Ken Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1083006 Share on other sites More sharing options...
M.O.S. Studios Posted July 8, 2010 Author Share Posted July 8, 2010 The problem isn't in the function. I removed the function and replaced it with echo session_id();. I then placed it into the 2nd script manually. what i found is that the session data stays as is until i load the 2nd script, then it disappears. Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1083010 Share on other sites More sharing options...
kenrbnsn Posted July 8, 2010 Share Posted July 8, 2010 Can you show us how you're generating the session id in your first script. I don't see that in any of the code you've posted so far. Ken Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1083015 Share on other sites More sharing options...
M.O.S. Studios Posted July 8, 2010 Author Share Posted July 8, 2010 this is my code as it stand now <?php if($_POST['submit']==BUTTMAKEACCOUNT){ if($_GET['section']=='newaccount'){ SESSION_START(); $_SESSION['newmember']['email']=$_POST['newmember_email']; $_SESSION['newmember']['password']=$_POST['newmember_password']; $_SESSION['newmember']['username']=$_POST['newmember_username']; $_SESSION['newmember']['fname']=$_POST['newmember_firstname']; $_SESSION['newmember']['lname']=$_POST['newmember_lastname']; $_SESSION['newmember']['tmp_pass']=randstr('15', TRUE, FALSE); echo SESSION_ID(); } } ?> <?php echo $error; ?> <form method='POST' action='index.php?page=members§ion=newaccount'> <div class='newmember'> <div class='section'><?php echo MEMBERS_LOGININFO; ?></div> <div class='email'><?php echo EMAIL; ?></div> <div class='email_input'><input name='newmember_email' value='<?php echo $_POST['newmember_email']; ?>' type='text' size='15' maxlength='25'></div> <div class='password'><?php echo PASSWORD; ?></div> <div class='password_input'><input name='newmember_password' value='<?php echo $_POST['newmember_password']; ?>'type='password' size='8' maxlength='8'></div> <div class='passwordcon'><?php echo CONPASSWORD; ?></div> <div class='passwordcon_input'><input name='newmember_conpassword' value='<?php echo $_POST['newmember_conpassword']; ?>' type='password' size='8' maxlength='8'></div> <div class='section'><?php echo MEMBERS_PROFILEINFO; ?></div> <div class='username'><?php echo MEMBERS_USER; ?></div> <div class='username_input'><input name='newmember_username' type='text' size='15' maxlength='25' value='<?php echo $_POST['newmember_username']; ?>'></div> <div class='firstname'><?php echo MEMBERS_FIRSTNAME; ?></div> <div class='firstname_input'><input name='newmember_firstname' type='text' size='15' maxlength='25' value='<?php echo $_POST['newmember_firstname']; ?>'></div> <div class='lastname'><?php echo MEMBERS_LASTNAME; ?></div> <div class='lastname_input'><input name='newmember_lastname' type='text' size='15' maxlength='25' value='<?php echo $_POST['newmember_lastname']; ?>'></div> <div class='submit'><input type='submit' name='submit' value='<?php echo BUTTMAKEACCOUNT; ?>'></div> </div> </form> Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1083031 Share on other sites More sharing options...
M.O.S. Studios Posted July 8, 2010 Author Share Posted July 8, 2010 ok, so i got it working, Had to do a HUGE work around. first had to add this line to the index.php of my cms session_save_path('common/sessions'); then change the 2nd script to this $string = fread(fopen('../../common/sessions/sess_'.$_GET['sid'], 'r'), filesize('../../common/sessions/sess_'.$_GET['sid'])); session_start(); session_decode($string); print_r($_SESSION); this is an INSAINE amount of work just to call a session. this will work, but if some one know wtf is going on let me know Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1083042 Share on other sites More sharing options...
kenrbnsn Posted July 8, 2010 Share Posted July 8, 2010 I tried your original code and it worked fine on my xampp system and my linux box. There must be something weird going on on your box. Ken Link to comment https://forums.phpfreaks.com/topic/206996-session_id/#findComment-1083058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.