• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Need to display only array value in JSON output

Laravel Factory not calling callback 'afterCreating'

How to get multiple values with same key from an array PHP

How to get transaction details in notify_url page in paypal

PHPSpreadsheet - How Do I Use Auto Migration Tool

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

How to fix bootstrap multiselect search data using ajax

Handling expired token in Laravel

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

How to show selected value using javascript in laravel

How to upload mpdf file after generating to s3 bucket in php

Alert message after submitting form in PHP

Printing more than one array using print_r or any other function in php

Laravel 8 Multiple Relationships for Factory

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

About Contact Privacy policy Terms and conditions