1

I want show a modal if session is exist, I am tried like this but it's not showing

<?php if(isset($_SESSION['Message1'])) { ?>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria- labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="myModalLabel">Welcome...</h4>
  </div>
  <div class="modal-body">
    This is test 
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <button type="button" class="btn btn-primary">Save changes</button>
   </div>
  </div> 
 </div>
</div>
<script type="text/javascript">
  $(window).load(function(){        
  $('#myModal').modal('show');
}); 
</script>
<?php } ?>

Thanx in advance

Arslan
  • 433
  • 1
  • 5
  • 17

2 Answers2

0

Maybe this will help you.

Instead of $(window).load() try

$( "#myModal" ).load(function() {
  $('#myModal').modal('show');
});
Aram Grigoryan
  • 740
  • 1
  • 6
  • 24
0

you just forgot to started the session. so just added this line before you checked the session.

session_start();