storing and retrieving session from one page to another

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Hi all

In my index page, i have added textarea and a button. User will enter the comments in textarea and clicks the button then it will open a modal dialog, which is having social logins(facebook, google). And the after logging in, it will open home page. In that home page , the comment which user has entered in index page has to be displayed.

For me modal dialog with social logins are working and it is redirecting to home page , but textareA comment is not passing from index page to home page.
Code for social logins i have used from OAuth Login for Facebook Twitter and Google Plus Using PHP.
So please tell me how to pass text from index to home page. On button click event, it has ti open the modal dialog and also it has to carry the text to home page using php.
My code is
index.php

<body>


<div class="container-fluid">
<div class="row">
<div class="col-md-offset-4 col-lg-offset-4 col-md-4 col-lg-4">
Story: <br><textarea id="ta1" maxlength="1000" cols="50" rows="4"></textarea>
maxlength="1000"<br>

<button id='modal-launcher' class="btn btn-primary btn-lg" data-toggle="modal" data-target="#login-modal" >
Post
</button>
</div>
</div>
</div>




<div class="modal fade" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header login_modal_header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h2 class="modal-title" id="myModalLabel">Login to Your Account</h2>
</div>
<div class="modal-body login-modal">

<br/>
<div class="clearfix"></div>
<div id='social-icons-conatainer'>

<div class="modal-social-icons">
<a class="btn btn-default facebook" href="login.php?type=facebook"> <i class="fa fa-facebook modal-icons"></i> Signin with Facebook </a>
<a class="btn btn-default google" href="login.php?type=google"> <i class="fa fa-google-plus modal-icons"></i> Signin with Google </a>
<a class="btn btn-default twitter" href="login.php?type=twitter"> <i class="fa fa-twitter modal-icons"></i> Signin with Twitter </a>

</div>

</div>

</div>
</div>
</div>

<script src="js/jquery.validate.min.js"></script>
<script src="js/login.js"></script>
</body>
</html>
<?php

$_SESSION['story'] = $_POST['limitedtextarea'];
?>


home.php


<div class="content">
<div class="container">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="well text-center">
<p>Welcome</p>

</div>


</div>


</div>
</div>

if(isset($_SESSION['story'])) {
echo "Your session is running " . $_SESSION['story'];
}
?>
 
You have to start a session on each page.

Add this at the top of each page :

Code:
<?php
session_start();
?>

Oh, and use the CODE button when you add code to your post. It's easier to read and to copy.
 
thanx for ur reply.
i have already ADDED THE session start
I donna weather u understood the code how it will work r not.
In my index.php page i have added a textarea and a button.
if user enters the text and clicks a button, first a modal dialog with social logins(facebook, google) will open. And then when user logins it will redirect to home .php page where the text has to be displayed.
But if i add the form in index.php page then modal dialog is not opening thatswhy i dint added the form.
 
Back
Top