• 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

Fetch files from next cloud storage and display in Laravel website

PHP usort() order in case of equality

using random function but it's displaying duplicates

PHP's array_map including keys

Form Validation and Submission to database

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

How to use $this->session->set_userdata in codeigniter

Google Gmail API - How to login programatically?

I want to store data in new index as per my key in php [duplicate]

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

Statement that checks whether a URL contains a particular path?

Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works

PHP error: "The zip extension and unzip command are both missing, skipping."

Can't find vendor/autoload.php for Ratchet

About Contact Privacy policy Terms and conditions