Jump to content

session_id()


M.O.S. Studios

Recommended Posts

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

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&section=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

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

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&section=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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.